Toolbar
A bar of tool buttons with roving focus.
Install and use
The first command adds the component and the Mine theme, the second adds this example. Render <Mine> once near your root for the skin, sounds and narrator.
"use client"
import { Toggle, ToggleIcon } from "@/components/ui/toggle"
import { Toolbar, ToolbarButton, ToolbarSeparator } from "@/components/ui/toolbar"
import { BoldIcon, ItalicIcon, LinkIcon, UnderlineIcon } from "lucide-react"
import { useLog } from "@/demos/log"
const styles = [
{ label: "Bold", icon: BoldIcon },
{ label: "Italic", icon: ItalicIcon },
{ label: "Underline", icon: UnderlineIcon },
]
function Example() {
const log = useLog()
return (
<Toolbar aria-label="Formatting">
{styles.map(({ label, icon: Icon }) => (
<Toggle
key={label}
aria-label={label}
onPressedChange={(pressed) =>
log(`${label} ${pressed ? "on" : "off"}`)
}
>
<ToggleIcon>
<Icon />
</ToggleIcon>
</Toggle>
))}
<ToolbarSeparator />
<ToolbarButton
aria-label="Insert link"
onClick={() => log("Insert link")}
>
<LinkIcon aria-hidden="true" />
</ToolbarButton>
</Toolbar>
)
}
export { Example }