CSS selectors reference
Complete reference of all .fern-* selectors available for customizing your documentation site.
Fern selectors use Tailwind CSS utilities and CSS custom properties. Write custom styles that complement existing styles rather than override them completely.
Layout and structure
Selectors for controlling the overall page layout, background styling, and page heading appearance.
.fern-background-image
Applies a fixed background image to the documentation layout that won’t scroll with page content.
.fern-page-heading
Styles the primary heading (h1) on documentation pages with balanced text wrapping and automatic word breaking to prevent overflow.
Header components
Selectors for customizing the site header, including the logo container, search bar, navigation tabs, and mobile menu button.
.fern-header
Container for the documentation site header with a frosted glass backdrop blur effect.
.fern-header-tabs
Container for navigation tabs in the header, hidden on mobile and visible on desktop (1024px+) with matching blur effect.
.fern-header-logo-container
Container for the site logo in the header.
.fern-header-search-bar
Container for the search input in the header, hidden on mobile and visible on desktop.
Sidebar components
Selectors for styling the sidebar navigation, including headers, links, groups, and tabs.
.fern-sidebar-header
Header section at the top of the sidebar.
.fern-sidebar-heading
Heading for sidebar navigation sections.
.fern-sidebar-heading-content
Text content of sidebar section headings.
.fern-sidebar-link
Individual navigation link in the sidebar with hover and active states using grayscale and accent colors.
.fern-sidebar-link-title
Text content of sidebar navigation links, truncated with ellipsis by default with optional marquee animation or wrapping.
.fern-sidebar-link-title-inner
Enables marquee animation for long sidebar link titles (disabled when prefers-reduced-motion is set).
.fern-sidebar-group
Container for grouped sidebar navigation items.
.fern-sidebar-tabs
Container for tab navigation in the sidebar.
Navigation components
Selectors for breadcrumb navigation elements and separators.
.fern-breadcrumb
Container for breadcrumb navigation.
.fern-breadcrumb-item
Individual link or text in breadcrumb navigation.
.fern-breadcrumb-arrow
Separator icon between breadcrumb items.
Button components
Selectors for styling buttons with various variants, sizes, and states.
.fern-button
Styled button element with multiple variants (minimal, filled, outlined, primary, success, warning, danger), size modifiers (small, large, square), and support for rounded and multiline styles.
Variants:
.minimal- Transparent background with subtle hover.filled- Solid background color.outlined- Border with transparent background.primary- Accent color variant.success- Green color variant.warning- Amber color variant.danger- Red color variant
Size modifiers:
.small- Smaller button (height: 1.75rem on desktop, 1.5rem on mobile).large- Larger button (height: 2.75rem on desktop, 2.5rem on mobile).square- Square button with equal width and height
.fern-button-content
Wrapper for button content including icons and text.
.fern-button-text
Text element inside button.
.fern-button-group
Container for grouping multiple buttons together.
.fern-copy-button
Button for copying code snippets or text, appears on hover over code blocks.
.fern-expand-button
Button for expanding code blocks or collapsible content, appears on code blocks with maxLines set.
Card components
Selectors for card-style content blocks with interactive and elevated variants.
.fern-card
Container for card-style content blocks with interactive and elevated variants, automatically styling nested lists and adapting to dark mode.
Variants:
.interactive- Adds hover effects.elevated- Elevated appearance with accent border.active- Active state styling
Form components
Selectors for form inputs, text areas, checkboxes, radio buttons, and other form controls.
.fern-input
Styled text input element with hidden number spinners and increased font size on mobile for better usability.
.fern-input-group
Container for input with additional elements (icons, buttons), with focus ring and error state styling.
.fern-input-icon
Icon element within input group.
.fern-input-right-element
Element positioned on the right side of input (e.g., clear button).
.fern-textarea
Multi-line text input element.
.fern-textarea-group
Container for textarea with additional styling.
.fern-checkbox-label
Label element wrapping checkbox input.
.fern-checkbox-item
Styled checkbox input.
.fern-checkbox-indicator
Visual indicator when checkbox is checked.
.fern-radio-group
Container for grouped radio buttons.
.fern-radio-label
Label element wrapping radio input.
.fern-radio-item
Styled radio button input.
.fern-radio-indicator
Visual indicator when radio button is selected.
.fern-segmented-control
Toggle control with multiple options.
.fern-numeric-input-group
Number input with increment/decrement buttons.
.fern-numeric-input-step
Increment/decrement button in numeric input.
Dropdown and selection components
Selectors for dropdown menus, selection items, and product selector components.
.fern-dropdown
Container for dropdown menu content.
.fern-dropdown-item
Individual selectable item in dropdown.
.fern-dropdown-item-indicator
Icon showing selected state in dropdown item.
.fern-selection-item
Large selectable item with icon and title, used in product selector.
.fern-selection-item-icon
Icon container in selection item.
.fern-selection-item-title
Title text in selection item.
.fern-selection-item-end-icon
Icon at the end of selection item (e.g., arrow).
.fern-product-selector
Container for product selection dropdown applied to the FernDropdown component wrapper. Custom styling can be applied for specific layouts. See the fern-api/docs repo styles.css file for advanced customization examples.
.fern-product-selector-radio-group
Radio button group within the product selector dropdown. Can be customized with CSS grid for multi-column layouts. See the fern-api/docs repo styles.css file for examples.
Accordion components
Selectors for expandable accordion containers, items, triggers, and animations.
.fern-accordion
Container for accordion component.
.fern-accordion-item
Single expandable item in accordion.
.fern-accordion-trigger
Clickable trigger to expand/collapse accordion item.
.fern-accordion-trigger-arrow
Arrow icon indicating expand/collapse state.
.fern-accordion-trigger-title
Title text in accordion trigger.
Scroll area components
Selectors for custom scrollable areas with styled scrollbars and viewports.
.fern-scroll-area
Container for custom scrollable area.
.fern-scroll-area-viewport
Viewport element containing scrollable content.
.fern-scroll-area-scrollbar
Styled scrollbar element.
.fern-scroll-area-thumb
Draggable thumb element in scrollbar. The ::before pseudo-element increases touch target size for accessibility.
.fern-scroll-area-corner
Corner element where horizontal and vertical scrollbars meet.
Badge components
Selectors for small labels and status indicators, including HTTP method and status code badges.
.fern-docs-badge
Small badge for labels, status indicators, HTTP methods, etc. HTTP method badges use monospace font and support color variants based on HTTP method or status code.
MDX content components
Selectors for content elements within MDX documentation, including links, callouts, steps, and tables.
.fern-mdx-link
Styled link element in documentation content. External links automatically get an icon, and underline thickness increases on hover.
.fern-callout
Highlighted callout box for important information. Each intent has matching background, border, and text colors, and icons within callouts are automatically colored.
Intent variants:
[data-intent="info"]- Gray/neutral (default)[data-intent="warning"]- Amber/yellow[data-intent="success"]- Green[data-intent="error"]- Red[data-intent="note"]- Blue[data-intent="launch"]- Accent color[data-intent="tip"]- Green[data-intent="check"]- Green
.fern-steps
Container for step-by-step instructions.
.fern-step
Single step in steps component.
.fern-anchor
Anchor link for deep linking to sections. Positioned absolutely within step components and includes a .fern-anchor-icon child element with hover and copied states.
.fern-table-root
Root container for table component with card-style styling. Used for custom table implementations and provides base styling for table layouts.
.fern-table
Styled table element with consistent spacing and borders. Supports a .sticky modifier for sticky table headers that remain visible during scrolling.
API Reference components
Selectors for API Reference documentation, including property names, metadata, and containers.
.fern-api-property
Container for API property documentation.
.fern-api-property-header
Header section of API property.
.fern-api-property-key
Property name in API documentation.
.fern-api-property-meta
Metadata for API property (type, required, etc.).
Utility components
Selectors for miscellaneous utility elements like highlights, icons, tooltips, and footer.
.fern-highlight
Highlighted/emphasized text element.
.fern-mdx-icon
Icon element in documentation content for inline icons in text. Automatically adapts to light and dark mode using CSS variables.
.fern-mdx-tooltip-trigger
Element that triggers tooltip on hover for inline tooltips. Provides CSS custom properties (--tooltip-underline-color, --tooltip-underline-hover-color, etc.) for customizing underline appearance.
.fern-mdx-tooltip-content
Content displayed in tooltip, positioned absolutely relative to trigger. Provides a --tooltip-padding-x CSS custom property for customizing horizontal padding.
.fern-file-icon
Icon representing a file type used in selection items and file browsers. Automatically scales to 1.2× on hover when used within .fern-selection-item.
.fern-collapsible-child
Child element within collapsible content for nested collapsible sections. Automatically animates with slide-down and slide-up effects when parent collapsible opens or closes.
.fern-runnable-endpoint
Interactive API endpoint that can be executed in API playground features. Provides special styling for lists, buttons, and disabled inputs within the component.
.fern-rss-feed-button
Button for subscribing to RSS feeds.
Light and dark mode customization
Techniques for creating styles that automatically adapt between light and dark themes using CSS variables.
Fern applies theme-specific CSS variables that automatically adapt to light and dark modes. Light mode uses the .light and :root selectors, while dark mode uses the .dark selector. Use Fern’s CSS custom properties so your styles automatically adapt across themes.
Key CSS variables
Fern provides the following CSS variables for theming:
Color scales:
--accent-1through--accent-12- Accent color scale--accent-a1through--accent-a12- Accent color scale with alpha transparency--grayscale-1through--grayscale-12- Grayscale color scale--grayscale-a1through--grayscale-a12- Grayscale with alpha transparency
Theme variables:
--background- Page background color--card-background- Card background color--border- Border color--sidebar-background- Sidebar background color--header-background- Header background color--accent- Primary accent color
Dynamic backgrounds
Use CSS variables to create backgrounds that automatically adapt to the theme. Override with .dark selector only when you need theme-specific styling.
Dynamic cards
Cards automatically adapt to theme changes when using CSS variables. Add explicit dark mode overrides only for properties like shadows that need theme-specific values.
Dynamic text
Text colors automatically adapt when using Fern’s grayscale and accent variables. Use --grayscale-12 for primary text, --grayscale-a11 for secondary text, and --accent-11 for links.
Dynamic images
There are multiple approaches for adapting images to light and dark modes.
SVG icons with currentColor (recommended):
Swapping background images:
Using picture element with prefers-color-scheme:
The prefers-color-scheme media query follows the operating system theme preference and may not match a manual theme toggle on your site. For perfect alignment with Fern’s theme switcher, use the .dark selector approach instead.
Using CSS filters (last resort):
Avoid hardcoding hex colors in your custom CSS. Always use Fern’s CSS variables to maintain proper contrast and theme consistency.