grafana/public/app/features/variables/editor/VariableSwitchField.tsx
Torkel Ödegaard 314865dd88
InlineSwitch: Added missing InlineSwitch component and fixed two places that used unaligned inline switch (#30162)
* InlineSwitch: Added missing InlineSwitch component and fixed two places that used unaligned inline switch

* Fixed e2e tests
2021-01-11 10:50:17 +01:00

24 lines
660 B
TypeScript

import React, { ChangeEvent, PropsWithChildren, ReactElement } from 'react';
import { InlineField, InlineSwitch } from '@grafana/ui';
interface VariableSwitchFieldProps {
value: boolean;
name: string;
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
tooltip?: string;
ariaLabel?: string;
}
export function VariableSwitchField({
value,
name,
tooltip,
onChange,
ariaLabel,
}: PropsWithChildren<VariableSwitchFieldProps>): ReactElement {
return (
<InlineField label={name} labelWidth={20} tooltip={tooltip}>
<InlineSwitch label={name} value={value} onChange={onChange} aria-label={ariaLabel} />
</InlineField>
);
}