Get Started
Components
Dev Tools
More Guides
Button Group
A Button Group component is a UI element that groups multiple buttons together, allowing users to select from a set of related actions or options. It helps organize buttons in a compact, cohesive layout, typically displayed in a horizontal or vertical row. Button Groups are useful for actions that are closely related or mutually exclusive, providing a clean and structured way to present multiple controls.
# Demo
# Attributes
Name | Type | Default | Details |
---|---|---|---|
className | string | ' ' | You can customise by passing tailwind classes. |
buttonClassName | string | ' ' | You can customise by passing tailwind classes. |
items | string[] | Required | You can pass items for the button group. |
selected | string | Required | You can pass default selected item. |
disabled | boolean | false | You can pass disable state to disable items. |
onChange | (selected: string) => void | Required | You can get callback when button group changed. |
# Usage
import { useState } from 'react';
import { NButtonGroup } from 'nayan';
const items = ['Startup', 'Business', 'Enterprise'];
const ButtonGroup = () => {
const [selected, setSelected] = useState(items[0]);
return <NButtonGroup disabled={false} items={items} selected={selected} onChange={setSelected} />;
};
export default ButtonGroup;
# Tags