Extending the system
import
"@truvar-ai/design-system"Extending the system
When you need something React Aria doesn't ship, you either add behaviour to an existing component or compose a new one from its primitives. Both keep the accessibility work done for you.
export function ConfirmButton({ onConfirm, children }) {
const [armed, setArmed] = useState(false);
const m = useMessages(); // built-in English + Arabic strings
return (
<Button variant="danger"
onPress={() => armed ? onConfirm() : setArmed(true)}
onBlur={() => setArmed(false)}>
{armed ? m.pressAgain : children}
</Button>
);
}How useful was this result?Not rated yet
export function Rating({ label, max = 5, onChange }) {
return (
<RadioGroup orientation="horizontal" onChange={onChange}>
<Label>{label}</Label>
{range(1, max).map((n) => (
<Radio key={n} value={String(n)} aria-label={m.of(n, max)}
className="tv-rating-dot" />
))}
</RadioGroup>
);
}