@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
42 lines (41 loc) • 1.59 kB
TypeScript
import type { ComponentChildren } from 'preact';
type RadioValue = string | number;
export type RadioProps<T extends RadioValue> = {
value: T;
/** Content provided as children is vertically aligned with the radio icon */
children: ComponentChildren;
/**
* Allows to provide extra content to be displayed under the children, in a
* smaller and more subtle font color.
*/
subtitle?: ComponentChildren;
disabled?: boolean;
};
declare function Radio<T extends RadioValue>({ value, children, subtitle, disabled: radioDisabled, }: RadioProps<T>): import("preact").JSX.Element;
declare namespace Radio {
var displayName: string;
}
export type RadioGroupProps<T extends RadioValue> = {
children: ComponentChildren;
selected?: T;
onChange: (newSelected: T) => void;
/**
* Determines the direction in which radios are stacked.
* Defaults to 'horizontal'.
*/
direction?: 'vertical' | 'horizontal';
disabled?: boolean;
'aria-label'?: string;
'aria-labelledby'?: string;
/**
* If provided, adds a hidden form control with the given name and the value
* set to the selected radio's value, for use in form submissions.
*/
name?: string;
};
declare function RadioGroupMain<T extends RadioValue>({ direction, children, selected, onChange, disabled, 'aria-label': label, 'aria-labelledby': labelledBy, name, }: RadioGroupProps<T>): import("preact").JSX.Element;
declare const RadioGroup: typeof RadioGroupMain & {
Radio: typeof Radio;
displayName: string;
};
export default RadioGroup;