Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Guides

Using Cynosure without React

Pages that don't run React (Astro pages, static sites, plain TypeScript apps) can still use Cynosure's tokens and icons. They do not get the components: those are React, because the components are what provide keyboard, focus and accessibility behaviour.

TokensLink to "Tokens"

The quickest way is the default theme as plain CSS:

html
Copy
<link rel="stylesheet" href="node_modules/@arshad-shah/cynosure/dist/styles/tokens.css" />

or, with a bundler, import "@arshad-shah/cynosure/styles/tokens.css";. Every --cy-* custom property is then available to your own CSS:

css
Copy
.card {
  background: var(--cy-color-surface);
  color: var(--cy-color-ink);
  border-radius: var(--cy-radius-md);
  padding: var(--cy-space-4);
}

For your own accent, scale or palette, build the CSS from a theme with the React-free @arshad-shah/cynosure/tokens entry, at build time or in a small script:

ts
Copy
import { createTheme, themeToCss } from "@arshad-shah/cynosure/tokens";

const css = themeToCss(createTheme({ accent: "#2f66b0", scale: "compact" }));
// write `css` to a file, or inline it in a <style> in the page head

The same entry has the named-theme helpers (defineTheme, createThemeRegistry), resolveColors(theme, palette) for a canvas or chart that needs concrete colours, and the editor and chart theme builders (monacoTheme, textMateTheme, swiftChartTheme); see Theming.

With Vite (Astro uses Vite too), the adapter does this for you: see docs/adapters.md.

Light and dark without a flashLink to "Light and dark without a flash"

themeInitScript() returns a tiny script that sets the saved colour mode before the first paint. Inline it in the <head> (not in browser extensions: their pages block inline scripts):

astro
Copy
---
import { themeInitScript } from "@arshad-shah/cynosure/tokens";
---
<script is:inline set:html={themeInitScript({ key: "my-site-theme" })}></script>

IconsLink to "Icons"

iconToSvg returns the same SVG markup as the React Icon. Load @arshad-shah/cynosure/styles/icon.css (or styles.css) so it is sized and coloured the same way.

ts
Copy
import { iconToSvg, search } from "@arshad-shah/cynosure/icons";
import { github } from "@arshad-shah/cynosure/brands";

button.innerHTML = iconToSvg(search, { label: "Search" });
footer.innerHTML += iconToSvg(github, { size: 20, label: "GitHub" });

In Astro, render it into the page with <Fragment set:html={iconToSvg(search)} />. See docs/icons.md for the brand marks and how brands allow their marks to be used.

Interactive piecesLink to "Interactive pieces"

Where a page needs a real control (a theme toggle, a form, a dialog), use the React component as an island (in Astro, @astrojs/react and a client: directive) inside CynosureTheme.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog