An action with a persistent pressed state.
import { useState } from 'react';
import { ToggleButton } from '@vrum/ui';
export default function Demo() {
const [pressed, setPressed] = useState(false);
return (
<ToggleButton
pressed={pressed}
variant={"outline"}
size={"md"}
disabled={false}
onPressedChange={setPressed}
>
{"Bold"}
</ToggleButton>
);
}Copy code| Prop | Type | Default | Description |
|---|---|---|---|
pressed | boolean | none | Controlled pressed state. |
defaultPressed | boolean | none | The state of the toggle when initially rendered. Use `defaultPressed` if you do not need to control the state of the toggle. |
onPressedChange | ((pressed: boolean) => void) | none | The callback that fires when the state of the toggle changes. |
asChild | boolean | none | as child configuration. |
disabled | boolean | none | Disable user interaction. |
name | string | none | name configuration. |
type | "submit" | "reset" | "button" | none | type configuration. |
value | string | number | readonly string[] | none | Controlled value. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content displayed inside the component. |
onFocus | FocusEventHandler<HTMLButtonElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLButtonElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLButtonElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLButtonElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLButtonElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLButtonElement> | none | on select configuration. |
variant | "outline" | "default" | "default" | Visual appearance within the Vrum design system. |
size | "sm" | "md" | "lg" | "md" | Size of the component. |