DocSearchButton component renders the search button that triggers the DocSearch modal. It’s rendered automatically by the DocSearch component but can also be used standalone for custom implementations.
Import
Usage
Props
TheDocSearchButton component extends native HTML button props and accepts all standard button attributes (className, onClick, etc.).
Theme applied to the button styling.
Localized strings for the button text and aria labels.Object with optional properties:
buttonText(string, default: “Search”): Button text displayed in the buttonbuttonAriaLabel(string, default: “Search”): Aria label for accessibility
Configuration for keyboard shortcuts display.Object with optional properties:
'Ctrl/Cmd+K'(boolean): Whether to show the Ctrl/Cmd+K keyboard shortcut hint
All standard HTML button attributes are supported, including:
onClick: Click event handlerclassName: CSS class namestyle: Inline stylesdisabled: Disabled statetype: Button type- And all other native button attributes
Button Structure
The button renders with the following structure:Keyboard Shortcut Display
The button automatically detects the user’s operating system and displays the appropriate keyboard shortcut:- macOS: Shows ⌘K
- Windows/Linux: Shows Ctrl+K
Ref
The component supportsReact.forwardRef and forwards the ref to the underlying button element:
Styling
The button uses BEM-style CSS classes for styling:DocSearch: Base DocSearch namespaceDocSearch-Button: Main button classDocSearch-Button-Container: Container for icon and textDocSearch-Button-Placeholder: Text placeholderDocSearch-Button-Keys: Container for keyboard shortcutDocSearch-Button-Key: Individual key in the shortcutDocSearch-Button-Key--pressed: Applied when key is pressedDocSearch-Button-Key--ctrl: Specific styling for Ctrl key
