Selectable Input
Selectable inputs allow users to choose from a set of options. They display an icon above text and provide clear visual feedback for selected and unselected states.
Overview
Selectable inputs are interactive components that allow users to select from a set of options. They feature an icon above text and provide clear visual feedback through background color and border changes when selected or unselected.
All selectable input styles are built using design tokens, ensuring consistency across themes and hues. Use the interactive playground below to explore all available combinations.
Interactive Playground
Use the controls to customize the selectable input and see how it looks in real-time.
<SelectableInput />Anatomy
A selectable input consists of several parts that work together to create a cohesive selection control.
Visual representation above textText description below iconBorder, padding, border-radius, backgroundVariants & States
Selectable inputs support different sizes and states to accommodate various use cases.
Sizes
smmdlgxlStates
DefaultSelectedDisabledUsage Guidelines
- Use selectable inputs for choosing from a set of options.
- Provide clear, descriptive labels for each option.
- Use meaningful icons that represent the option.
- Group related selectable inputs together.
- Provide clear visual feedback for selected state.
- Use appropriate sizes based on context and importance.
- Ensure sufficient spacing between selectable inputs.
- Don't use selectable inputs for navigation (use buttons or links instead).
- Don't use selectable inputs for text input (use input fields instead).
- Don't use too many selectable inputs in a single view.
- Don't disable selectable inputs without explaining why.
- Don't use unclear or ambiguous icons.
- Don't use selectable inputs for destructive actions.
- Don't make labels too long or wrap awkwardly.
Accessibility
- Always provide clear labels for selectable inputs using the label prop.
- Ensure sufficient color contrast between text and background in both selected and unselected states.
- Provide keyboard navigation support (Tab to navigate, Space/Enter to select).
- Use aria-pressed attribute to indicate selected state.
- Ensure selectable inputs are large enough to be easily clickable (minimum 44x44px touch target).
- Provide clear visual feedback for all interactive states (hover, focus, selected).
- Use disabled state appropriately and provide alternative ways to access disabled options if needed.
API Reference
Selectable input component props and types.
SelectableInputProps
interface SelectableInputProps {
label?: string;
icon?: React.ReactNode;
size?: "sm" | "md" | "lg" | "xl";
selected?: boolean;
disabled?: boolean;
cornerRadius?: CornerRadiusStep;
fullWidth?: boolean;
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
}Props
labelstring"Option"iconReact.ReactNodeGridUILayoutIconsize"sm" | "md" | "lg" | "xl""md"selectedbooleanfalsedisabledbooleanfalsecornerRadiusCornerRadiusStep2fullWidthbooleanfalseonClick(e: React.MouseEvent<HTMLButtonElement>) => voidUsage Examples
Copyable code snippets for common selectable input use cases.
Basic Selectable Input
import { SelectableInput } from 'beacon-ui';
<SelectableInput
label="Option"
/>Selected State
import { SelectableInput } from 'beacon-ui';
<SelectableInput
label="Option"
selected
/>With Custom Icon
import { SelectableInput } from 'beacon-ui';
import { GridUILayoutIcon } from 'beacon-icons';
<SelectableInput
label="Option"
icon={<GridUILayoutIcon size="sm" />}
/>Multiple Options
import { SelectableInput } from 'beacon-ui';
<div style={{ display: 'flex', gap: 'var(--spacing-200)' }}>
<SelectableInput label="Option 1" />
<SelectableInput label="Option 2" selected />
<SelectableInput label="Option 3" />
</div>