Baseline Status
The <BaselineStatus>
component displays browser support for a given web feature according to the Baseline project.
This component is based on the official <baseline-status>
custom element, but avoids using any client-side JavaScript.
Usage
The above code produces the following result:
Scroll snap
Baseline Widely available
Supported in Chrome: yes.
Supported in Edge: yes.
Supported in Firefox: yes.
Supported in Safari: yes.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020
The id
attribute
The <BaselineStatus>
component requires an id
attribute which sets the web feature to display browser support data for.
This ID is the slug of the feature as stored in the web-platform-dx/web-features
repository.
The Web Platform Status site is also a helpful place to search for feature IDs.
For example, the ID for the CSS :has()
selector is "has"
:
:has()
Baseline 2023 newly available
Supported in Chrome: yes.
Supported in Edge: yes.
Supported in Firefox: yes.
Supported in Safari: yes.
Since December 2023 this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
If the ID does not match a known web feature, the component will still render, but display an unknown availability. For example, with an ID of "rainbow-unicorns"
:
rainbow-unicorns
Unknown availability
Supported in Chrome: unknown.
Supported in Edge: unknown.
Supported in Firefox: unknown.
Supported in Safari: unknown.
We currently don’t have browser support information about this feature.
Styling the component
Due to its relatively complex layout and content, the <BaselineStatus>
component uses Declarative Shadow DOM to isolate its markup from your site’s styles.
You can override the default styles using the ::part()
pseudo-element.
The above styles would render <BaselineStatus>
like this:
Anchor positioning
Limited availability
Supported in Chrome: yes.
Supported in Edge: yes.
Supported in Firefox: no.
Supported in Safari: no.
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Light/dark theming support
The default styles make a best effort to adapt automatically to a site’s color theme.
By default, text color is inherited from the document styles and the component has a transparent background. Colors used in iconography adapt to the user’s color scheme preference using a prefers-color-scheme
media query.
In browsers that support the light-dark()
CSS function, if your site sets the correct color-scheme
values, <BaselineStatus>
will adapt to match the current theme even if it does not match system-level color scheme preferences.
light-dark()
Baseline 2024 newly available
Supported in Chrome: yes.
Supported in Edge: yes.
Supported in Firefox: yes.
Supported in Safari: yes.
Since May 2024 this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Supporting a custom theme picker
If your site uses a theme picker to set the current theme and you need to support older browsers, you can add custom styles to control the color variables <BaselineStatus>
uses.
For example, if you use a data-theme="dark"
attribute to enable dark mode on your site, configure colors when that is set:
See “Custom properties API” below for a full list of available variables.
Custom properties API
The <BaselineStatus>
component supports the following API for controlling its styles with CSS custom properties.
CSS class names API
The root element of the <BaselineStatus>
component can be targeted using the .baseline-status
selector.
In addition, the following variant class names are applied and can be used to customise appearance for the different Baseline status levels:
.baseline-status--limited
: applied if the feature has limited availability.baseline-status--newly
: applied if the feature is newly available.baseline-status--widely
: applied if the feature is widely available.baseline-status--no_data
: applied if there is no data available for the feature
For example, you could use these to display custom colors only for widely available features:
Cascade layers
Baseline Widely available
Supported in Chrome: yes.
Supported in Edge: yes.
Supported in Firefox: yes.
Supported in Safari: yes.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2022
Component parts API
The following component parts are exposed to set custom styles in your CSS.
::part(root)
Selects the wrapper at the base of the component. Particularly useful for setting CSS variables that impact component styles.
::part(feature-name)
The name of the feature support information is being displayed for.
::part(details)
The <details>
element.
::part(summary)
The <summary>
element.
::part(summary-content)
The main content of the <summary>
element. This includes the visible text (summary-label
) and browser icons (browsers
), but excludes the Baseline icon and disclosure caret (caret
).
::part(summary-label)
Element specifying the global support level in the <summary>
, e.g. text reading “Baseline: Widely available” or “Limited availability”.
::part(badge)
Badge element added to highlight newly available Baseline features.
::part(browsers)
Wrapper element around the browser support icons.
::part(browser-support)
A browser support lockup, including browser logo, support level icon, and accessible text label.
::part(browser-support-label)
Accessible text label for browser support, visually hidden by default.
::part(caret)
The disclosure caret displayed instead of the default <details>
marker.
::part(description)
The detailed description of the support level visible when the component is expanded.
::part(link)
The link element visible when the component is expanded.
Standalone installation
If you only need the <BaselineStatus>
component, you can install the package directly instead of the main astro-embed
package:
The <BaselineStatus>
component can then be imported as: