Fusion UI LogoFusion UI Logo
Fusion UI LogoFusion UI Logo
/
Getting Started
Concepts
Components
Example Apps
Getting Started
Concepts
Components
Example Apps
Fusion UI LogoFusion UI Logo
Getting Started
Concepts
Components
Example Apps
Overview
Actions
Button
Button Group
Segmented Button
Deprecated
Split Button
Toggle Button
Click To Copy
Toolbar
Navigation
Main Nav
Side Menu
Page Header
Tabs
Breadcrumbs
On-Page Menu
Link
Command Menu
Application Switcher
Context Switcher
Account Menu
Menu Bar
Deprecated
Inputs & Forms
Form
Form Actions
Deprecated
Form Divider
Form Field
Form Repeat
Form Spacing
Input
Prefix & Suffix
Rich Text Input
Autocomplete
Select
Date / Time Input
Calendar
Slider
Selection
Checkbox
Radio
Switch
Switch Select
Chip
Chip Choice
Chip Filter
Chip Input
Chip Sortable
Visual Select
Pricing Plan Select
Feedback & Loading
Banner
Inline Message
Snackbar
Inline Snackbar
Loading Spinner
Skeleton
Text Skeleton
Contextual Information
Badge
Status
Tag
Tooltip
Info
Hotkey
Icon
Icon Sizer
Containers & Overlays
Tile
Tile Content
Tile Footer
Tile Header
Annotated Section
Modal
Sheet
Popover
Context Menu
Data Display
Data Table
List
Timeline
Data Visualization
KPI Card
Ratio Card
Bar Chart
Line Chart
Pie Chart
Heatmap Calendar
Layout
Container
Stack Layout
Flow Layout
Internals
Blanket
Expansion Panel
Menu List Base
Menu Group
Search Bar
Components
...
Hotkey

Hotkey

Shows a keyboard shortcut and optionally registers it.

Overview

Hotkey displays a keyboard shortcut and can register it at the same time, so the hint and the behavior never drift apart. Keys are shown with the symbols of the platform, e.g. ⌘ on macOS.

Press Ctrl+I to increment the count

Press Ctrl+⇧+I to decrement the count

Count: 0

"use client";
import React, {useState} from "react";
import {Hotkey, useHotkey} from "@brynlabs/fusion-ui";
export const HotkeyExample = () => {
const [count, setCount] = useState(0);
useHotkey(["action", "i"], () => setCount(prevCount => prevCount + 1), {scopes: ["global"]});
useHotkey(["action", "shift", "i"], () => setCount(prevCount => prevCount - 1), {
scopes: ["global"],
});
return (
<div>
<p>
Press <Hotkey hotkey={["action", "i"]} /> to increment the count
</p>
<p>
Press <Hotkey hotkey={["action", "shift", "i"]} /> to decrement the count
</p>
<p>Count: {count}</p>
</div>
);
};

Types

Global hotkeys work everywhere, scoped ones only within their scope.

Global Hotkeys

Press Ctrl+I to increment the count

Press Ctrl+⇧+I to decrement the count

Global Count: 0

Scoped Hotkeys

Press Ctrl+I to increment the count

Scoped Count: 0

Displaying Hotkeys

You can display Hotkeys like this Ctrl+⇧+I

Special Keys

'action' // Command (meta) on mac, Control (ctrl) on Windows/Linux

"use client";
import React, {useState} from "react";
import {Hotkey, useHotkey, useHotkeyScope} from "@brynlabs/fusion-ui";
export const HotkeyTypesExample = () => {
const [count, setCount] = useState(0);
useHotkey(["action", "i"], () => setCount(prevCount => prevCount + 1), {scopes: ["global"]});
useHotkey(["action", "shift", "i"], () => setCount(prevCount => prevCount - 1), {
scopes: ["global"],
});
const [count2, setCount2] = useState(0);
useHotkey(["action", "i"], () => setCount2(prevCount => prevCount + 1), {
scopes: ["custom-scope"],
});
useHotkeyScope("custom-scope", true, true);
return (
<div style={{display: "flex", flexDirection: "column", gap: "20px", width: "fit-content"}}>
<div>
<h4 className={"heading-4-font"}>Global Hotkeys</h4>
<p>
Press <Hotkey hotkey={["action", "i"]} /> to increment the count
</p>
<p>
Press <Hotkey hotkey={["action", "shift", "i"]} /> to decrement the count
</p>
<p>Global Count: {count}</p>
</div>
<div>
<h4 className={"heading-4-font"}>Scoped Hotkeys</h4>
<p>
Press <Hotkey hotkey={["action", "i"]} /> to increment the count
</p>
<p>Scoped Count: {count2}</p>
</div>
<div>
<h4 className={"heading-4-font"}>Displaying Hotkeys</h4>
<p>
You can display Hotkeys like this <Hotkey hotkey={["action", "shift", "i"]} />
</p>
</div>
<div>
<h4 className={"heading-4-font"}>Special Keys</h4>
<p>'action' // Command (meta) on mac, Control (ctrl) on Windows/Linux</p>
</div>
</div>
);
};

Layout

Single Layout: Ctrl+C

Multi Layout: CtrlC

"use client";
import React from "react";
import {Hotkey} from "@brynlabs/fusion-ui";
export const HotkeyLayoutExample = () => (
<div>
<p>
Single Layout: <Hotkey layout={"single"} hotkey={["action", "c"]} />
</p>
<p>
Multi Layout: <Hotkey layout={"multi"} hotkey={["action", "c"]} />
</p>
</div>
);

Styles

Copy Ctrl+C

Copy Ctrl+C

Copy Ctrl+C

Copy ⇧+⌥+C,⇧⌥C

Copy ⇧+++⌥+++C

Copy ⇧+⌥+C

Copy ⇧⌥C

Copy ⇧⌥C

Copy Ctrl⌥I

Copy Ctrl⇧I

"use client";
import React from "react";
import {Hotkey} from "@brynlabs/fusion-ui";
export const HotkeyStylesExample = () => (
<div>
<p className="body-font">
Copy <Hotkey hotkey={["action", "C"]} />
</p>
<p className="heading-6-font">
Copy <Hotkey hotkey={["action", "C"]} />
</p>
<div
style={{background: "green", padding: "0 4px", borderRadius: "3px", display: "inline-block"}}
className="button-font">
Copy <Hotkey hotkey={["action", "C"]} />
</div>
<p className="body-font">
Copy <Hotkey hotkey={["⇧", "⌥", "C"]} />,
<Hotkey layout={"multi"} hotkey={["⇧", "⌥", "C"]} />
</p>
<p className="body-font">
Copy <Hotkey hotkey={["⇧", "+", "⌥", "+", "C"]} />
</p>
<p className="body-font">
Copy <Hotkey hotkey={["⇧"]} />+<Hotkey hotkey={["⌥"]} />+<Hotkey hotkey={["C"]} />
</p>
<p className="heading-1-font">
Copy <Hotkey layout={"multi"} hotkey={["⇧", "⌥", "C"]} />
</p>
<p className="heading-5-font">
Copy <Hotkey layout={"multi"} hotkey={["⇧", "⌥", "C"]} />
</p>
<p>
Copy <Hotkey layout={"multi"} hotkey={["action", "⌥", "I"]} />
</p>
<p>
Copy <Hotkey layout={"multi"} hotkey={["action", "⇧", "I"]} />
</p>
</div>
);
On this page
  • Overview
  • Types
  • Layout
  • Styles