Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@primer/react

primer136.1kMIT37.21.0TypeScript support: included

An implementation of GitHub's Primer Design System using React

react, components, library, design-system

readme

Primer logo

Primer React

A React implementation of GitHub's Primer Design System

npm package contributors graph last commit license

Documentation

Our documentation site lives at primer.style/react. You'll be able to find detailed documentation on getting started, all of the components, our theme, our principles, and more.

Installation

Install @primer/react in your project with your package manager of choice:

npm install @primer/react
yarn add @primer/react

Template

The fastest way make a prototype or try Primer React without setting up a new project is by using our react template.

Contributing

We love collaborating with folks inside and outside of GitHub and welcome contributions!

👉 See the contributing docs for more info on code style, testing, coverage, and troubleshooting.

New Component Proposals

We welcome and encourage new component proposals from internal GitHub teams! Our best work comes from collaborating directly with the teams using Primer React Components in their projects. If you'd like to kick off a new component proposal, please submit an issue using the component proposal issue template and we will get in touch!

changelog

@primer/react

37.21.0

Minor Changes

Patch Changes

37.20.0

Minor Changes

Patch Changes

37.19.1

Patch Changes

  • Update data table pagination pageEnd to handle zero based index

  • b926c08 Thanks @AAugustine! - Update data table pagination pageEnd to handle zero based index

37.19.0

Minor Changes

Patch Changes

  • #5866 f978534 Thanks @mperrotti! - Improves how we detect context for inactive item messaging by checking the role on ActionList instead of relying on parent components, making the logic more robust and consistent. It also fixes incorrect behavior in NavList and SelectPanel, and improves accessibility by correcting aria relationships on tooltip buttons.

  • #5912 81821db Thanks @francinelucca! - fix(SelectPanel): always show x button on single select

  • #5908 8e7bc0e Thanks @francinelucca! - fix(SelectPanel): differentiate onCancel gesture from escape

  • #5904 a522fdb Thanks @francinelucca! - fix(SelectPanel): disable body scroll on full screen

  • #5906 8fa12ea Thanks @TylerJDev! - SelectPanelV2: Add deprecated status to SelectPanelV2 docs and stories

  • #5881 ea1fb50 Thanks @emilybrick! - fix(SelectPanel): Add margin around notice styles

37.18.0

Minor Changes

Patch Changes

37.17.0

Minor Changes

Patch Changes

37.16.0

Minor Changes

  • #5763 d3926d1 Thanks @hussam-i-am! - chore(Box): Mark Box and its props as deprecated

  • #5772 0970415 Thanks @jonrohan! - Removing the CSS modules feature flag from the SubNav component.

  • #5785 fbd7fc9 Thanks @jonrohan! - Remove CSS modules feature flag from VisuallyHidden

  • #5760 8b492cf Thanks @TylerJDev! - Radio: Removes aria-invalid and aria-required from Radio, as they are not supported on the element's role.

  • #5759 76bf60d Thanks @siddharthkp! - AnchoredOverlay: Add prop to set responsive variant. Example: variant: {regular: 'anchored', narrow: 'anchored'}

  • #5725 d3b48b1 Thanks @lukasoppermann! - Allow button count prop to accept a number or a string, to allow for human format, like 3.2k

Patch Changes

37.15.0

Minor Changes

Patch Changes

37.14.0

Minor Changes

Patch Changes

37.13.0

Minor Changes

Patch Changes

37.12.0

Minor Changes

Patch Changes

37.11.2

N/A, re-release of v37.11.1

37.11.1

Patch Changes

37.11.0

Minor Changes

Patch Changes

37.10.0

Minor Changes

Patch Changes

  • #5488 e352e19 Thanks @hectahertz! - Pagination: Hides the Pagination Previous and Next buttons from the accessibility tree when they are disabled.

37.9.1

Patch Changes

  • 8c1cff4 Thanks @francinelucca! - fix(ActionList): remove className from menuItemProps to prevent duplicate className bug

37.9.0

Minor Changes

Patch Changes

37.8.0

Minor Changes

Patch Changes

37.7.2

Patch Changes

37.7.1

Patch Changes

37.7.0

Minor Changes

Patch Changes

37.6.0

Minor Changes

Patch Changes

37.5.0

Minor Changes

Patch Changes

37.4.0

Minor Changes

Patch Changes

37.3.0

Minor Changes

Patch Changes

37.2.0

Minor Changes

  • #5168 b9749d4 Thanks @TylerJDev! - TreeView: Adds indication of no nodes in a tree item, allows for `aria-expanded even if the item is empty.

  • #5202 293c574 Thanks @hussam-i-am! - Update SubNav component to use CSS modules behind the feature flag primer_react_css_modules_team

Patch Changes

37.1.0

Minor Changes

Patch Changes

37.0.1

Patch Changes

37.0.0

Major Changes

Minor Changes

Patch Changes

37.0.0-rc.11

Minor Changes

Patch Changes

37.0.0-rc.10

Minor Changes

Patch Changes

  • #5059 682e787 Thanks @gwwar! - Fixes negative and invalid pages in data table pagination on re-render.

  • #5078 3b7bf41 Thanks @jonrohan! - Set the min-width of IconButton to unset to resolve layout issues.

  • #5062 0f5d5e0 Thanks @jonrohan! - Move CSS modules feature flag from staff to ga for Avatar component

  • #5082 212714c Thanks @langermank! - Add focus styles to Pagination component

  • #5077 6490b27 Thanks @jonrohan! - Bug fix(Avatar): Changed rounded border calculation for the "square" Avatar to better align with existing border styles

  • #5055 73135c1 Thanks @francinelucca! - fix(Banner): rewrite PrimaryAction & SecondaryAction types

  • #5068 5f7bd0b Thanks @jonrohan! - fix for toggleStyledComponent utility, When the feature flag is enabled and sx prop is passed in use, Box

  • #5091 4218bef Thanks @jonrohan! - Bug fix for IconButton to respect the style prop width when the feature flag is on.

  • #5073 472967a Thanks @siddharthkp! - SelectPanel: Fix items not being selected when defined within scope (track selection by item.id)

  • #5066 702ba5c Thanks @jonrohan! - Use the IconButton for the close button on Dialog

  • #5079 a2e5671 Thanks @jonrohan! - Correctly pass styled system typography and common props to the Box component in the Text component when the CSS modules feature flag is enabled.

37.0.0-rc.9

Minor Changes

Patch Changes

37.0.0-rc.8

Major Changes

  • #4992 d1d911a Thanks @joshblack! - Move Octicon, Pagehead, Dialog (v1), and Tooltip (v1) to @primer/react/deprecated

Patch Changes

37.0.0-rc.7

Major Changes

Minor Changes

Patch Changes

  • #5026 3302440 Thanks @siddharthkp! - Banner: Fix alignment of secondary action without primary action

  • #5018 8e4beae Thanks @jonrohan! - Remove the CSS modules feature flag from Heading

  • #5023 1691e46 Thanks @jonrohan! - Move Button component feature flag from primer_react_css_modules_team to primer_react_css_modules_staff

  • #5020 31f03fb Thanks @jonrohan! - Move Text component feature flag from primer_react_css_modules_staff to primer_react_css_modules_ga

  • #5001 597d285 Thanks @jonrohan! - Migrate ButtonGroup component to use CSS modules behind the primer_react_css_modules_team feature flag

  • #5022 4395d16 Thanks @jonrohan! - Move Label component feature flag from primer_react_css_modules_staff to primer_react_css_modules_ga

  • #4969 0cd6151 Thanks @TylerJDev! - Add initial loading state to live region announcement in TreeView

  • #5024 45f3597 Thanks @jonrohan! - Move Avatar component feature flag from primer_react_css_modules_team to primer_react_css_modules_staff

  • #5011 7a5205d Thanks @langermank! - Bug fix: Button aria-expanded state (CSS Modules)

37.0.0-rc.6

Major Changes

  • #4953 04e8c9c Thanks @iansan5653! - Delete deprecated draft components MarkdownEditor, MarkdownInput, and InlineAutocomplete

Minor Changes

Patch Changes

  • #5000 b8f6888 Thanks @jonrohan! - Text component CSS module feature flag changed to primer_react_css_modules_staff

  • #4975 0b89fc0 Thanks @jonrohan! - Change the Link component feature flag from primer_react_css_modules_staff to primer_react_css_modules_ga

  • #4981 c8fe1c6 Thanks @jonrohan! - Removes the feature flag from the Blankslate component to always render with CSS modules.

  • #4986 d6471aa Thanks @francinelucca! - fix(Dialog): track mousedown event to prevent accidental closing

  • #4967 98d3d13 Thanks @TylerJDev! - Utilizes [disabled] selector instead of :disabled in TooltipV2 to address a false positive

  • #4977 1adea12 Thanks @siddharthkp! - SelectPanel: Add role=combobox to filter input (behind feature flag primer_react_select_panel_with_modern_action_list)

  • #4971 ff56b04 Thanks @jonrohan! - Changed Heading feature flag from primer_react_css_modules_staff to primer_react_css_modules_ga

  • #4989 dc80aa6 Thanks @camertron! - Allow color to be customized for medium-sized IconButtons

  • #4968 da0f48b Thanks @siddharthkp! - SelectPanel: Add announcements for screen readers (behind feature flag primer_react_select_panel_with_modern_action_list)

  • #4970 44a3dc9 Thanks @joshblack! - Update tab in UnderlinePanels to set explicit type

  • #5000 b8f6888 Thanks @jonrohan! - Label component CSS module feature flag changed to primer_react_css_modules_staff

  • #4995 8a1ee22 Thanks @lukasoppermann! - ProgressBar: Adding default gap between sections for progressbars with more than one section

  • #4966 c097e96 Thanks @siddharthkp! - SelectPanel: Fix focus and selection styles for Windows high contrast themes (behind feature flag primer_react_select_panel_with_modern_action_list)

  • #4997 dc2d1f3 Thanks @TylerJDev! - Popover: Add note on deprecation of caret in v38

  • #4987 b82286d Thanks @langermank! - Bump stylelint + fixes

37.0.0-rc.5

Major Changes

  • #4785 b74c47f Thanks @joshblack! - The drafts entrypoint has been removed from @primer/react. Use @primer/react/experimental instead.

  • #4940 4d3b504 Thanks @langermank! - Refactor ButtonBase component to use CSS modules behine flag

Minor Changes

  • #4951 c9009de Thanks @francinelucca! - fix(Pagination): Use anchor instead of button for disabled prev/next controls

  • #4885 373ce95 Thanks @jonrohan! - Refactor Avatar component to use CSS modules behind feature flag

  • #4906 dbf82f4 Thanks @siddharthkp! - SelectPanel: Support <kbd>PageDown</kbd> and <kbd>PageUp</kbd> for keyboard navigation

    SelectPanel: Label listbox by the title of the panel

Patch Changes

  • #4910 c2e4d5e Thanks @TylerJDev! - Changes the accessible name of the "toggle" button in LabelGroup to contain the visual label

  • #4941 80fe025 Thanks @langermank! - Bug fix: Button loading spinner color

  • #4957 6874b89 Thanks @langermank! - Add missing wide CSS + className to Stack

  • #4648 c6931d2 Thanks @siddharthkp! - ActionMenu: Make sure event handlers on ActionMenu.Button and ActionMenu.Anchor are called

  • #4972 082b4e7 Thanks @joshblack! - Update issue where FormControl.Caption was rendering incorrectly when CSS Modules flags were enabled

  • #4794 5f996c6 Thanks @broccolinisoup! - SelectPanel: Update SelectPanel to use modern ActionList behind a feature flag primer_react_select_panel_with_modern_action_list

  • #4954 af7f589 Thanks @joshblack! - Banner: Update alignment of actions when it is dismissible and has a hidden title

  • #4943 c282642 Thanks @langermank! - Button bug fixes: invisible variant icon colors missing variables + icon button disabled state

37.0.0-rc.4

Minor Changes

  • #4893 1b098ed Thanks @jonrohan! - Refactor Label to use CSS modules behind the primer_react_css_modules_team feature flag

  • #4884 46dc2f3 Thanks @langermank! - Bump primer/primitives v9

  • #4923 1dded73 Thanks @jonrohan! - Move the Blankslate css modules feature flag to primer_react_css_modules_ga

  • #4779 551aff3 Thanks @TylerJDev! - Adds dependencies to Dialog focus trap to ensure focus trap is reset when content within changes

  • #4874 4c69b38 Thanks @jonrohan! - Refactor Text to CSS modules behind primer_react_css_modules_team feature flag

Patch Changes

37.0.0-rc.3

Patch Changes

37.0.0-rc.2

Major Changes

Minor Changes

Patch Changes

37.0.0-rc.1

Minor Changes

Patch Changes

37.0.0-rc.0

Major Changes

Minor Changes

Patch Changes

36.27.0

Minor Changes

Patch Changes

36.26.0

Minor Changes

Patch Changes

36.25.0

Minor Changes

Patch Changes

36.24.0

Minor Changes

Patch Changes

36.23.0

Minor Changes

Patch Changes

36.22.0

Minor Changes

36.21.0

Minor Changes

Patch Changes

36.20.0

Minor Changes

36.19.1

Patch Changes

36.19.0

Minor Changes

Patch Changes

36.18.0

Minor Changes

Patch Changes

36.17.0

Minor Changes

Patch Changes

36.16.0

Minor Changes

36.15.0

Minor Changes

Patch Changes

36.14.0

Minor Changes

Patch Changes

36.13.0

Minor Changes

Patch Changes

36.12.0

Minor Changes

Patch Changes

36.11.0

Minor Changes

Patch Changes

36.10.0

Minor Changes

Patch Changes

36.9.0

Minor Changes

Patch Changes

36.7.1

Patch Changes

36.7.0

Minor Changes

  • #4157 aafa257e1 Thanks @langermank! - - Adds CSS variable color values to the legacy Primitive design tokens.
    • Three values include: the new v8 color CSS variable, a fallback of the old color CSS variable, and the raw value.

Patch Changes

36.6.0

Minor Changes

  • #3787 c9d74219d Thanks @langermank! - - Moves legacy color primitives from primer/primitives directly into Primer React

    • Cleans up unused dependencies on primitives other than color
    • Preparing for the upgrade to CSS variables (Primitives v8)
  • #3994 c40f76562 Thanks @maximedegreve! - ActionMenu: Only use checkmarks in menus instead of checkboxes

  • #4135 c2b069cfd Thanks @dipree! - Deprecate the underline property of the Link component in favor of the new inline property to better handle link visibility and accessibility when adjacent to text.

  • #4145 996475f7b Thanks @siddharthkp! - experimental/SelectPanel: Add SelectPanel.SecondaryAction

  • #4128 359213b29 Thanks @joshblack! - Add "use client" to package entrypoints to support React Server Components

Patch Changes

36.5.0

Minor Changes

Patch Changes

36.4.0

Minor Changes

  • #3982 968d4ef05 Thanks @joshblack! - Update SSRProvider, useSSRSafeId to use the native React 18 useId() instead of @react-aria/ssr

  • #3812 3f82a1cab Thanks @mperrotti! - Adds an 'inactive' state to buttons. An inactive button looks disabled and has aria-disabled, but it can still be clicked and focused. This was added to support buttons that are broken due to availability issues, but can't be removed from the page.

Patch Changes

36.3.1

Patch Changes

36.3.0

Minor Changes

Patch Changes

  • #3897 6b0c118b3 Thanks @mperrotti! - When passing an id prop to ActionMenu.Button, it will be passed as the rendered button element's id attribute instead of being set as an automatically generated ID.

  • #3960 ec8a2cadd Thanks @pksjce! - Update to @primer/behaviors v1.5.1

  • #3945 40b29787e Thanks @siddharthkp! - ActionList: Fix bug that did not allow both inline and block description at the same time

  • #3903 f62ec728a Thanks @pksjce! - Make resize vertical splitter keyboard accessible

  • #3946 e08432d54 Thanks @siddharthkp! - Link: Add inline prop to tag links inside a text block, underlined with accessibility setting [data-a11y-link-underlines]

  • #3983 43d1dce4a Thanks @TylerJDev! - Readjust order of PageLayout.Pane contents

  • #3972 87028d2b9 Thanks @iulia-b! - Update MarkdownEditor to correctly identify non-standard formatted tasklist items

36.2.0

Minor Changes

  • #3900 2f9b5869 Thanks @broccolinisoup! - ActionList: Add ActionList.GroupHeading component to label the group lists and update labelling semantics for accessibility

  • #3143 cc0c16e9 Thanks @green6erry! - Adjusts position of children within PageLayout.Pane to live above adjustable resize form.

Patch Changes

36.1.0

Minor Changes

Patch Changes

36.0.0

Major Changes

  • #3384 3633535c Thanks @joshblack! - Update styled-components and related dependencies to v5.x

  • #3384 3633535c Thanks @joshblack! - Remove components from deprecated

    • BorderBox, ChoiceFieldset, Flex, Grid, Position, Dropdown, FormGroup, SelectMenu, InputField, Label
  • #3384 3633535c Thanks @joshblack! - Remove components from draft bundle

    • Move UnderlineNav2 (draft) to the main bundle
    - import {UnderlineNav} from '@primer/react/drafts'
    + import {UnderlineNav} from '@primer/react'

    ....

    • Remove TreeView from drafts
    - import {TreeView} from '@primer/react/drafts'
    + import {TreeView} from '@primer/react'
    • Remove SegmentedControl from drafts
    - import {SegmentedControl} from '@primer/react/drafts'
    + import {SegmentedControl} from '@primer/react'
    • Remove NavList from drafts
    - import {NavList} from '@primer/react/drafts'
    + import {NavList} from '@primer/react'
    • Remove SplitPageLayout from drafts
    - import {SplitPageLayout} from '@primer/react/drafts'
    + import {SplitPageLayout} from '@primer/react'
  • #3384 3633535c Thanks @joshblack! - - Changes leadingIcon and trailingIcon to leadingVisual and trailingVisual

    • Removes Button.Counter as a child component, replacing it with a count prop. This change allows us to use the trailingVisual slot for counters.
    • Removes the outline button variant as we wish to only support invisible buttons.
  • #3384 3633535c Thanks @joshblack! - Remove deprecated extralarge variant from Token and TextInputWithToken component

  • #3384 3633535c Thanks @joshblack! - Remove StyledOcticon component. The component was renamed to Octicon. Update your imports by swapping StyledOcticon with Octicon

  • #3384 3633535c Thanks @joshblack! - Deprecates FilterList and FilteredSearch components

  • #3384 3633535c Thanks @joshblack! - Makes @types/styled-components an optional peer dependency, not a dependency

  • #3384 3633535c Thanks @joshblack! - ConfirmationDialog: Use createRoot instead of ReactDOM.render for React 18 compatibility.

  • #3384 3633535c Thanks @joshblack! - Update minimum version for react and react-dom to v18

  • #3384 3633535c Thanks @joshblack! - Remove DropdownButton and DropdownMenu from deprecated and update the usages across

  • #3384 3633535c Thanks @joshblack! - The Autocomplete component no longer uses the deprecated ActionList component. There have been minor API updates, but it's largely the same.

  • #3384 3633535c Thanks @joshblack! - Removes 'warning' option from form components' validationStatus props

  • #3384 3633535c Thanks @joshblack! - Remove support for activeClassName for Breadcrumb, SubNav, TabNav, UnderlineNav

  • #3384 3633535c Thanks @joshblack! - Ensure ActionList item has border-radius on hover with full variant

Patch Changes

35.32.2

Patch Changes

35.32.1

Patch Changes

35.32.0

Minor Changes

Patch Changes

35.31.0

Minor Changes

35.30.0

Minor Changes

  • #3714 88340269 Thanks @iansan5653! - Add support for controlling which side ActionMenu renders on (via a side prop on ActionMenu.Overlay)

  • #3715 1f889281 Thanks @joshblack! - Add support for leadingVisual and trailingVisual props to Button

  • #3739 b90e5476 Thanks @joshblack! - Add the Column type and createColumnHelper function to easily define columns for DataTable

  • #3719 500e529d Thanks @joshblack! - The UnderlineNav, FilterList, and FilteredSearch components will be deprecated in v36 and have been moved to the deprecated entrypoint. To use the new UnderlineNav, migrate to the component available in drafts.

  • #3732 8928acc3 Thanks @joshblack! - Add default type="button" to IconButton component

Patch Changes

35.29.0

Minor Changes

  • #3692 4046e058 Thanks @broccolinisoup! - Octicons: Upgrade react-octicons to v19.7.0

  • #3647 e480a4a4 Thanks @paxos! - Adds onSelectSuggestion callback to <InlineAutocomplete />

  • #3607 c0e22fc1 Thanks @langermank! - Update ActionList checkbox styles to form checkbox styles (impacts ActionMenu and SelectPanel)

  • #3632 3a8b841c Thanks @iansan5653! - Allow consumers to make components that are compatible with FormControl by reading forwarded props in from the useFormControlForwardedProps hook

Patch Changes

35.28.0

Minor Changes

  • #3563 3bb6dc8c Thanks @radglob! - Add option to specify custom widths for PageLayout.Pane via the width prop.

Patch Changes

35.27.1

Patch Changes

  • #3589 d598a53b Thanks @siddharthkp! - - PageLayout: Undo deprecation of position prop for PageLayout.Pane (Revert primer/react#3389)

    • SplitPageLayout: Undo deprecation of position prop for SplitPageLayout.Pane (Revert primer/react#3389)

35.27.0

Minor Changes

  • #3510 bdbcfd15 Thanks @camertron! - Implement accessibility audit feedback for ToggleSwitch

  • #3466 11b54ac8 Thanks @mperrotti! - Allows consumers to disable the behavior where the AvatarStack expands to show each Avatar on hover. There are also changes that allow users to customize the size of the avatars - even responsively!

  • #3390 b4e15b84 Thanks @mperrotti! - The showPages prop on both Pagination components can now accept a responsive value.

  • #3496 11cdbdcc Thanks @joshblack! - Update dependency ranges to use caret ranges instead of pinned versions

Patch Changes

35.26.1

Patch Changes

35.26.0

Minor Changes

Patch Changes

35.25.1

Patch Changes

  • #3174 d4c6ae5b Thanks @colebemis! - MarkdownEditor is now SSR-compatible.

    Warning: In this new implementation, MarkdownEditor.Toolbar, MarkdownEditor.Actions, and MarkdownEditor.Label must be direct children of MarkdownEditor.

  • #3209 a6279536 Thanks @langermank! - Remove --primer prefix from CSS var

  • #3173 6b900e90 Thanks @colebemis! - ActionList and NavList are now SSR-compatible.

    Warning: In this new implementation, ActionList.LeadingVisual, ActionList.TrailingVisual, and ActionList.Description must be direct children of ActionList. The same applies to NavList.

  • #3198 a273748b Thanks @langermank! - Bug fix: ButtonGroup borders show incorrectly on hover

35.25.0

Minor Changes

Patch Changes

  • #3124 5b3cf499 Thanks @mattcosta7! - replace createRef with useRef

  • #3149 4c2d121f Thanks @colebemis! - FormControl is now SSR-compatible.

    Warning: In this new implementation, FormControl.Caption, FormControl.Label, FormControl.LeadingVisual, and FormControl.Validation must be direct children of FormControl.

  • #3114 f5c7f299 Thanks @radglob! - Adds the option to declare multiple segments in a ProgressBar.

  • #3127 5224fcbf Thanks @siddharthkp! - Suppress SSR warning for useLayoutEffect in NavList, use useIsomorphicLayoutEffect instead of useLayoutEffect

  • #3165 d749f495 Thanks @broccolinisoup! - UnderlineNav2: Add transparent outline for focus to support WHCM

  • #3120 9e40fdf4 Thanks @simurai! - Bump @primer/primitives to 7.11.5

  • #3093 8b5307da Thanks @simurai! - Bump @primer/primitives to 7.11.3

  • #3097 a38c00e6 Thanks @colebemis! - TreeView is now SSR-compatible.

    Warning: In this new implementation, TreeView.LeadingVisual and TreeView.TrailingView must be direct children of TreeView.Item.

  • #3170 1f2df9b7 Thanks @lukasoppermann! - When an inline description is added to the item the normal text is set to bold

  • #3160 4b05b19e Thanks @joshblack! - Update PageLayout.Pane to provide a warning instead of an error when overflow is detected and no label has been provided

  • #3094 16cae51a Thanks @mperrotti! - Fixes styling issue where PointerBox would show a border between the caret and the box if the background color was transparent.

  • #3112 bd4e1393 Thanks @langermank! - Adds shadow and color change to IssueLabelToken on hover

  • #3146 a19b721c Thanks @colebemis! - CheckboxGroup and RadioGroup are now SSR-compatible.

    Warning: In this new implementation, CheckboxGroup.Caption, CheckboxGroup.Label, and CheckboxGroup.Validation must be direct children of CheckboxGroup. The same applies to RadioGroup.

35.24.0

Minor Changes

  • #3071 681e2271 Thanks @mperrotti! - Adds a helper component for rendering placeholder text to explain why a DataTable cell has no content.

  • #3089 4a6a9f73 Thanks @mperrotti! - Adds the ability to exclose indentation for flat tree views.

  • #3011 f8132d8e Thanks @edersonlucas! - Add the tooltipDirection property to the TextInput.Action component to make the tooltip position flexible.

Patch Changes

35.23.0

Minor Changes

  • #3068 09e11335 Thanks @mperrotti! - Adds text alignment option to columns

  • #3012 04d9db02 Thanks @radglob! - Adds tabIndex and role="region" to PageLayout.Pane when overflow is detected (scrollHeight > clientHeight). Also requires either aria-labelledby or aria-label when overflow is detected, and throws an error if neither is defined.

Patch Changes

35.22.0

Minor Changes

Patch Changes

  • #2996 baa63958 Thanks @mperrotti! - Implements column width features for the DataTable

  • #3036 51a2cc94 Thanks @colebemis! - PageLayout and SplitPageLayout are now SSR-compatible.

    Warning: In this new implementation, PageLayout.Header and PageLayout.Footer must be direct children of PageLayout. The same applies to SplitPageLayout

  • #3029 bb9f1561 Thanks @mperrotti! - Adds new a11y improvements to Pagination.

  • #2993 6aa9205e Thanks @mperrotti! - Makes StateLabel's 'status' prop required

  • #3009 cc4e2bc5 Thanks @iansan5653! - Recalculate autocomplete suggestions if the input data changes while the menu is open

  • #3010 022d449c Thanks @broccolinisoup! - SegmentedControl: Resolve axe-violation by adding a discernible text to the icon button and removing the tooltip until it is marked as accessible

35.21.0

Minor Changes

Patch Changes

35.20.0

Minor Changes

  • 5967b0a9 Thanks @broccolinisoup! - Issue a deprecation notice for UnderlineNav v1

  • #2815 74df59c4 Thanks @mperrotti! - Addresses feedback from the accessibility team about our SegmentedControl component. These changes include an update to ActionMenu that allows u to specify the ID of the DOM node that labels the menu.

  • #2768 5055b91b Thanks @green6erry! - Confine Heading as prop to header element types

  • #2903 13651ba1 Thanks @colebemis! - TreeView promoted to beta status. You can now import it from the main bundle instead of /drafts:

    - import {TreeView} from '@primer/react/drafts'
    + import {TreeView} from '@primer/react'

Patch Changes

  • #2792 03b470b0 Thanks @broccolinisoup! - - Add a block prop for full width

    • Add alignContent prop to align content to center or start for full width buttons
    • Use control sizing CSS variable values (not using CSS vars just yet)
    • Use height over padding for more control over sizing
    • Adjust invisible button variant to match new design using ActionList colors
  • #2868 03ebf41b Thanks @colebemis! - TreeView: Reliably move focus from loading item to first asynchronously loaded item

  • #2845 c31314c8 Thanks @colebemis! - TreeView: When moving focus to TreeView, the current item will be focused by default.

  • #2770 3bf1b0e3 Thanks @broccolinisoup! - UnderlineNav2: Handle the case when container is too small to render any items

  • d8f18435 Thanks @iansan5653! - Add aria-modal attribute to Dialog (V2) element

  • 3127e104 Thanks @jbrown1618! - Upgrade primer/behaviors from 1.3.1 to 1.3.2

  • 2a00aab6 Thanks @colebemis! - TreeView: Set aria-selected=true on focused item

  • ca7398df Thanks @broccolinisoup! - CounterLabel: Do not parse children to string for visually hidden content

  • #2900 3768cd7d Thanks @broccolinisoup! - PageHeader: A11y eng review remediations

  • 8bce9740 Thanks @broccolinisoup! - UnderlineNav2: Update total height of the navigation to 48px

  • 196a7929 Thanks @iansan5653! - Fix useDynamicTextareaHeight not taking into account top padding of textarea

    Also makes the hook accept a RefObject instead of an element instance

  • #2845 c31314c8 Thanks @colebemis! - TabNav: Re-focusing a TabNav will focus the selected tab

35.19.0

Minor Changes

Patch Changes

35.18.0

Minor Changes

Patch Changes

35.17.0

Minor Changes

Patch Changes

35.16.0

Minor Changes

Patch Changes

35.15.1

Patch Changes

35.15.0

Minor Changes

Patch Changes

35.14.2

Patch Changes

  • #2553 3a4b3124 Thanks @broccolinisoup! - UnderlineNav2: Only allow Enter and Space key to select an UnderlineNav item

  • #2506 a20faba0 Thanks @broccolinisoup! - UnderlineNav2: Prevent item width calculation when they are null

  • #2549 205e1d29 Thanks @mperrotti! - Adds a focus style to ActionList.LinkItem that is used when the primary input method is a cursor. Before this change, there was only a focus style for when the keyboard is being used as the primary input method.

  • #2546 8a8b1a4f Thanks @joshblack! - Add support for PageUp and PageDown for TreeView

  • #2485 e2a2d78c Thanks @broccolinisoup! - UnderlineNav2: Only run overflow layout function when nav item has a width

  • #2552 7877f895 Thanks @broccolinisoup! - UnderlineNav2: Add aria-hidden and sr-only class support for a descriptive "More" button label

  • #2550 e13e8ad7 Thanks @broccolinisoup! - UnderlineNav2: Remove focus zone and unnecessary 'Arrow keys' & 'Home' & 'End' button navigation support

  • #2551 5bc5c703 Thanks @broccolinisoup! - UnderlineNav2: Add aria-hidden and sr-only class support for descriptive counters

  • #2538 bdbccaaf Thanks @colebemis! - TreeView: Preserve expanded state of nested items when parent item is collapsed.

    Breaking change

    TreeView.Item and TreeView.LinkItem now require an id prop:

    - <TreeView.Item>...</TreeView.Item>
    + <TreeView.Item id="unqiue-id">...</TreeView.Item>

    This is not in a major release because TreeView is still a draft component.

  • #2555 dc1cf6da Thanks @josepmartins! - Remove deprecated components usage in Overlay stories

35.14.1

Patch Changes

35.14.0

Minor Changes

Patch Changes

35.13.0

Minor Changes

Patch Changes

35.12.0

Minor Changes

  • #2435 e335cc4b Thanks @colebemis! - SplitPageLayout has moved from @primer/react/drafts to @primer/react:

    - import {SplitPageLayout} from '@primer/react/drafts'
    + import {SplitPageLayout} from '@primer/react'

Patch Changes

35.11.0

Minor Changes

Patch Changes

35.10.0

Minor Changes

  • #2347 09a5d806 Thanks @mperrotti! - Adds a size prop to the SegmentedControl component. Users can choose between 'medium' (default), and 'small'. More sizes can be added when/if we find we need them.

  • #2324 027e44a7 Thanks @joshblack! - Update PageLayout.Pane to support a ref on the element wrapping children

Patch Changes

35.9.0

Minor Changes

Patch Changes

  • #2266 4cc6e52a Thanks @siddharthkp! - ActionMenu: Fix keyboard navigation for ActionMenu inside Overlay by re-enabling focus trap. It was disabled in v35.6.0, that led to a regression for ActionMenu within focus zones (example: AnchoredOverlay)

  • #2252 e52415e1 Thanks @joshblack! - Update ButtonBase.tsx to memoize calls to styles to improve performance

  • #2318 10305092 Thanks @iansan5653! - - Fix InlineAutocomplete accessibility hint affecting page layout outside of the suggestions

    • Fix suggestion icons not being visible in InlineAutocomplete items
  • #2206 3a38e6e3 Thanks @maximedegreve! - Add missing border on avatars

  • #2294 4536b87a Thanks @joshblack! - Change the default markup of PageLayout.Pane from <aside> to <div>

35.8.0

Minor Changes

Patch Changes

  • #2260 88b8c0e7 Thanks @iansan5653! - Add hooks in drafts/hooks to @primer/react/drafts exports

  • #2225 2c9bd012 Thanks @pksjce! - Add small variant to underline nav

  • #2236 8cc0efef Thanks @iansan5653! - Fix MarkdownViewer doc examples, add <kbd>Cmd/Ctrl+Shift+P</kbd> shortcut for toggling MarkdownEditor view mode, and strictly limit the type of the ref passed to MarkdownEditor.

  • #2242 d46ae9f3 Thanks @broccolinisoup! - Remove z-index assignment that used to be necessary for the dropdown children of FilteredSearch

  • #2188 8fc2e422 Thanks @siddharthkp! - Support React.ReactNode as child type in ActionMenu.Overlay

35.7.0

Minor Changes

  • #2232 a0fcce61 Thanks @broccolinisoup! - Add a stickyTop prop, the height of a sticky header, to the PageLayout.Pane to push the pane down for the sticky header when necessary.

  • #2228 bf99db99 Thanks @mperrotti! - Moves SegmentedControl to the main bundle and updates it's lifecycle status to "Alpha"

Patch Changes

35.6.0

Minor Changes

  • #2191 7edf1347 Thanks @mperrotti! - Adds responsive behavior to SegmentedControl's fullWidth prop.

  • #2174 62dbc981 Thanks @colebemis! - Add a responsive hidden prop to PageLayout.Header, PageLayout.Pane, PageLayout.Content, and PageLayout.Footer that allows you to hide layout regions based on the viewport width. Example usage:

    // Hide pane on narrow viewports
    <PageLayout.Pane hidden={{narrow: true}}>...</PageLayout.Pane>
  • #2199 fb385b63 Thanks @colebemis! - * Updated the position prop in PageLayout.Pane to use the new responsive prop API introduced in https://github.com/primer/react/pull/2174.

    • Deprecated the positionWhenNarrow prop in favor of the new responsive prop API

    Before

    position="start"
    positionWhenNarrow="end"

    After

    position={{regular: 'start', narrow: 'end'}}
  • #2201 885064ed Thanks @colebemis! - Add padding prop to PageLayout.Header, PageLayout.Content, PageLayout.Pane, and PageLayout.Footer

  • #2164 2b5c86e5 Thanks @mperrotti! - Adds support for a responsive 'variant' prop to the SegmentedControl component

  • #2212 04d9d9c1 Thanks @colebemis! - Add a sticky prop to the PageLayout.Pane component that provides a convenient way for you to make side panes sticky:

    <PageLayout>
    - <PageLayout.Pane>...</PageLayout.Pane>
    + <PageLayout.Pane sticky>...</PageLayout.Pane>
      <PageLayout.Content>...</PageLayout.Content>
    </PageLayout>
  • #2198 4d9b7db9 Thanks @colebemis! - * Updated the divider prop in PageLayout.Header, PageLayout.Pane, and PageLayout.Footer to use the new responsive prop API introduced in https://github.com/primer/react/pull/2174.

    • Deprecated the dividerWhenNarrow prop in favor of the new responsive prop API

    Before

    divider="line"
    dividerWhenNarrow="filled"

    After

    divider={{regular: 'line', narrow: 'filled'}}

Patch Changes

  • #2024 5321f1c9 Thanks @siddharthkp! - ActionMenu: Remove focus trap to enable Tab and Shift+Tab behavior and fix initial focus on click

  • #2186 e28aadbd Thanks @mperrotti! - Updates SegmentedControl styles to use component primitives.

  • #2171 384ae6b9 Thanks @anleac! - Support issues closed as not planned, and correct the standard issue closed backgroud colour

  • #2157 77e7ab05 Thanks @iansan5653! - Add InlineAutocomplete component, useCombobox hook, and useSyntheticChange hook to drafts

  • #2189 35716587 Thanks @mperrotti! - Makes SegmentedControl uncontrolled by default.

  • #2196 5ff5bb81 Thanks @mattcosta7! - update types to allow children for react 18

  • #2219 af534f15 Thanks @iansan5653! - Fix slots infinite rendering when no context prop is provided

  • #2182 47725a92 Thanks @iansan5653! - - Add MarkdownEditor and MarkdownViewer draft components. The MarkdownEditor is also known as the CommentBox component

    • Add useUnifiedFileSelect, useIgnoreKeyboardInputWhileComposing, useDynamicTextareaHeight, and useSafeAsyncCallback draft hooks
  • #2173 ed609719 Thanks @mperrotti! - Updates styles for the Select component so that the focus outline is even all the way around.

  • #2216 82fd8c35 Thanks @iansan5653! - Change createSlots to use layout effects when registering slots

  • #2185 3756a1ed Thanks @mattcosta7! - Set ConfirmationDialog initial focus based on the confirmationButtonVariant. When danger autoFocus the cancel button, otherwise autoFocus the confirmation button

  • #2166 75d21745 Thanks @mattcosta7! - button should be polymorphic

  • #2220 f4ef7b4b Thanks @mperrotti! - - Fixes role and keyboard behavior for SegmentedControl.

    • Fixes a bug where icon-only SegmentedControl buttons did not fill the parent width when the fullWidth prop was set
    • Fixes a bug where click handlers were not passed correctly when the responsive variant was set to 'hideLabels'
  • #2204 522f5806 Thanks @iansan5653! - Replace useCombinedRefs with useRefObjectAsForwardedRef

  • #2221 9ce64937 Thanks @josepmartins! - Overlay documentation fixes

35.5.0

Minor Changes

Patch Changes

  • #2150 63a2de51 Thanks @dgreif! - Ensure all files in lib-esm are in fact esm and not CommonJS

  • #2145 a2950ac4 Thanks @mperrotti! - Updates SegmentedControl component's keyboard navigation to align with the recommendations of GitHub's accessibility team.

  • #2143 d9b161a0 Thanks @mperrotti! - Fixes bugs in form components discovered while fixing/improving Storybook and docs.

35.4.0

Minor Changes

Patch Changes

  • #2099 40da598e Thanks @siddharthkp! - AnchoredOverlay: aria-expanded attribute is removed from anchor when overlay is not open

  • #2155 003cbcf0 Thanks @mperrotti! - Update Checkbox component to useIsomorphicLayoutEffect instead of useLayoutEffect to support SSR

  • #2154 96ad635b Thanks @mperrotti! - Allow "falsely/empty" Autocomplete.Input values

  • #2153 ce45de30 Thanks @willglas! - Add AutocompleteContext to Autocomplete component exports

  • #2105 c7bbd06f Thanks @siddharthkp! - ActionMenu: Replace typeahead behavior with single key mnemonics

  • #2125 78dc8134 Thanks @owenniblock! - Adds roles of tablist and tab to the TabNav component, required rearranging the HTML elements to be semantically correct

  • #2149 b3a98bac Thanks @dgreif! - Converted commonjs require of focus-visible to an esm import

  • #2120 53713b2f Thanks @colebemis! - Deprecate SideNav in favor of NavList.

    Before

    <SideNav aria-label="Main">
      <SideNav.Link href="/" selected>
        Home
      </SideNav.Link>
      <SideNav.Link href="/about">About</SideNav.Link>
      <SideNav.Link href="/contact">Contact</SideNav.Link>
    </SideNav>

    After

    <NavList aria-label="Main">
      <NavList.Item href="/" aria-current="page">
        Home
      </NavList.Item>
      <NavList.Item href="/about">About</NavList.Item>
      <NavList.Item href="/contact">Contact</NavList.Item>
    </NavList>
  • #2133 65fcd9f2 Thanks @mattcosta7! - Passthrough ActionList.Group props from NavList.Group

  • #2158 ac92de47 Thanks @owenniblock! - Fixes issue when tabs are not links

35.3.0

Minor Changes

Patch Changes

  • #2083 ea69ccd6 Thanks @ty-v1! - Export new Dialog component from the @primer/react/drafts bundle:

    - import {Dialog} from '@primer/react/lib-esm/Dialog/Dialog'
    + import {Dialog} from '@primer/react/drafts'
  • #2117 6e3532cf Thanks @dgreif! - Allow minor version updates for production dependencies

  • #2095 db5e629c Thanks @hectahertz! - Communicate the SelectPanel multi-select capability to assistive technologies.

35.2.2

Patch Changes

  • #2058 ab30f14a Thanks @colebemis! - Add draft of NavList component

  • #2038 1c2eeb9c Thanks @mperrotti! - Fixes accessibility bugs in the Select component.

  • #2076 05301033 Thanks @colebemis! - Draft NavList.Item now accepts an as prop, allowing it to be rendered as a Next.js or React Router link

  • #2082 3252b74c Thanks @mperrotti! - Fixes broken links in the documentation

  • #2075 56dbbd32 Thanks @colebemis! - Fix overflow issues in PageLayout.Content

    | Before | After | | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | image | image |

  • #2087 b319b29d Thanks @mperrotti! - Prevents the onRemove prop from being passed through to the HTML element from Token, AvatarToken, and IssueToken.

  • #2077 30f93ffb Thanks @colebemis! - Adds support for the sx prop on the draft implementation of NavList and all its subcomponents (e.g., NavList.Item)

  • #2050 0f9edcac Thanks @mperrotti! - Finishes updating components with the global focus styles defined in Primer CSS (this PR)

  • #2054 a682735f Thanks @colebemis! - Fixes layout bug with ButtonGroup by changing the display property from inline-block to inline-flex

  • #2064 62d90af8 Thanks @colebemis! - Add support for sub-items in draft implementation of NavList

  • #2057 c8f7e235 Thanks @mperrotti! - - adds color-scheme style to inputs so they get the correct user-agent dark/light styles

    • crops ToggleSwitch knob's shadow inside the toggle switch boundaries
    • changes FormControl styles to prevent <select>, <textarea>, <input> from filling the parent's width when the block prop has not been passed to the input component
  • #2048 4e15985b Thanks @siddharthkp! - ThemeProvider: Bug fix, in colorMode=auto, the theme now syncs with system changes.

35.2.1

Patch Changes

  • #2013 5f6c5e22 Thanks @mperrotti! - 1. Fix a spacing issue with the loading spinner in a TextInputWithTokens 2. Bolds form validation text to be visually balanced with the icon

  • #2053 231c70b9 Thanks @langermank! - Namespace UnderlineNav

  • #2033 0d7a871a Thanks @mperrotti! - - Text input inner action's hover bg should not touch the text input edges

    • Increases touch target area of the text input inner action button
    • Deprecated children and variant props on the TextInputInnerAction component, but they're still supported for now.

35.2.0

Minor Changes

Patch Changes

35.1.0

Minor Changes

Patch Changes

35.0.1

Patch Changes

35.0.0

Major Changes

  • #1893 17ef5ef8 Thanks @siddharthkp! -

    ActionList

    ⚠️ ActionList has been rewritten with a composable API, design updates and accessibility fixes.

    See full list of props and examples: https://primer.style/react/ActionList

    Before (v34) After (v35)
    <ActionList
      items={[
        {text: 'New file'},
        {text: 'Copy link'},
        {text: 'Edit file'},
        ActionList.Divider,
        {text: 'Delete file', variant: 'danger'},
      ]}
    />
    <ActionList>
      <ActionList.Item>New file</ActionList.Item>
      <ActionList.Item>Copy link</ActionList.Item>
      <ActionList.Item>Edit file</ActionList.Item>
      <ActionList.Divider />
      <ActionList.Item variant="danger">Delete file</ActionList.Item>
    </ActionList>
    <ActionList
      showItemDividers
      items={[
        {
          key: '0',
          leadingVisual: LinkIcon,
          text: 'github/primer',
        },
        {
          key: '1',
          leadingVisual: () => <Avatar src="https://github.com/mona.png" />,
          text: 'mona',
          description: 'Monalisa Octocat',
          descriptionVariant: 'block',
        },
        {
          key: '2',
          leadingVisual: GearIcon,
          text: 'View Settings',
          trailingVisual: ArrowRightIcon,
        },
      ]}
    />
    <ActionList showDividers>
      <ActionList.Item>
        <ActionList.LeadingVisual>
          <LinkIcon />
        </ActionList.LeadingVisual>
        github/primer
      </ActionList.Item>
      <ActionList.Item>
        <ActionList.LeadingVisual>
          <Avatar src="https://github.com/mona.png" />
        </ActionList.LeadingVisual>
        mona
        <ActionList.Description variant="block">Monalisa Octocat</ActionList.Description>
      </ActionList.Item>
      <ActionList.Item>
        <ActionList.LeadingVisual>
          <GearIcon />
        </ActionList.LeadingVisual>
        View settings
        <ActionList.TrailingVisual>
          <ArrowRightIcon />
        </ActionList.TrailingVisual>
      </ActionList.Item>
    </ActionList>
    <ActionList
      groupMetadata={[
        {groupId: '0', header: {title: 'Live query'}},
        {groupId: '1', header: {title: 'Layout'}},
      ]}
      items={[
        {key: '0', text: 'repo:github/github', groupId: '0'},
        {key: '1', text: 'Table', groupId: '1'},
        {key: '2', text: 'Board', groupId: '1'},
        {key: '3', text: 'View settings'},
      ]}
    />
    <ActionList>
      <ActionList.Group title="Live query">
        <ActionList.Item>repo:github/github</ActionList.Item>
      </ActionList.Group>
      <ActionList.Divider />
    
      <ActionList.Group title="Layout">
        <ActionList.Item>Table</ActionList.Item>
        <ActionList.Item>Board Description</ActionList.Item>
      </ActionList.Group>
      <ActionList.Divider />
    
      <ActionList.Item>View settings</ActionList.Item>
    </ActionList>

    To continue to use the deprecated API for now, change the import path to @primer/react/deprecated:

    import {ActionList} from '@primer/react/deprecated'

    You can use the one-time codemod to change your import statements automatically.

  • #1883 310e6553 Thanks @siddharthkp! - ActionList2 exported types are now prefixed with ActionList:

    ListProps → ActionListProps
    GroupProps → ActionListGroupProps
    ItemProps → ActionListItemProps
    DescriptionProps → ActionListDescriptionProps
    LeadingVisualProps → ActionListLeadingVisualProps,
    TrailingVisualProps → ActionListTrailingVisualProps

    ActionMenu2 exported types are now prefixed with ActionMenu:

    MenuButtonProps → ActionMenuButtonProps
    MenuAnchorProps → ActionMenuAnchorProps
  • #1897 d4023572 Thanks @siddharthkp! -

    ActionMenu

    ⚠️ ActionMenu has been rewritten with a composable API, design updates and accessibility fixes.

    See full list of props and examples: https://primer.style/react/ActionMenu

    Main changes:

    1. Instead of using items prop, use ActionList inside ActionMenu
    2. Instead of using anchorContent on ActionMenu, use ActionMenu.Button with children
    3. Instead of using onAction prop on ActionMenu, use onSelect prop on ActionList.Item
    4. Instead of using groupMetadata on ActionMenu, use ActionList.Group
    5. Instead of overlayProps on ActionMenu, use ActionMenu.Overlay
    Before (v34) After (v35)
    <ActionMenu
      anchorContent="Menu"
      onAction={fn}
      items={[
        {text: 'New file'},
        {text: 'Copy link'},
        {text: 'Edit file'},
        ActionMenu.Divider,
        {text: 'Delete file', variant: 'danger'},
      ]}
      overlayProps={{width: 'small'}}
    />
    <ActionMenu>
      <ActionMenu.Button>Menu</ActionMenu.Button>
      <ActionMenu.Overlay width="small">
        <ActionList>
          <ActionList.Item onSelect={fn}>New file</ActionList.Item>
          <ActionList.Item>Copy link</ActionList.Item>
          <ActionList.Item>Edit file</ActionList.Item>
          <ActionList.Divider />
          <ActionList.Item variant="danger">Delete file</ActionList.Item>
        </ActionList>
      </ActionMenu.Overlay>
    </ActionMenu>

    To continue to use the deprecated API for now, change the import path to @primer/react/deprecated:

    import {ActionMenu} from '@primer/react/deprecated'

    You can use the one-time codemod to change your import statements automatically.

  • #1898 d6d1ca4c Thanks @siddharthkp! -

    ⚠️ DropdownMenu has been deprecated in favor of ActionMenu with ActionList

    See example with selection: https://primer.style/react/ActionMenu#with-selection

    Migration guide:

    1. Instead of using items prop, use ActionList inside ActionMenu
    2. Use selectionVariant="single" on ActionList to set the right semantics for selection
    3. Instead of using selectedItem prop, use selected prop on ActionList.Item
    4. Instead of using renderAnchor and placeholder props on DropdownMenu, use ActionMenu.Button or ActionMenu.Anchor
    5. Instead of using onChange prop on DropdownMenu, use onSelect prop on ActionList.Item
    6. Instead of using groupMetadata on DropdownMenu, use ActionList.Group
    7. Instead of overlayProps on DropdownMenu, use ActionMenu.Overlay
    Before (v34) After (v35)
    const fieldTypes = [
      {key: 0, text: 'Text'},
      {key: 1, text: 'Number'},
      {key: 3, text: 'Date'},
      {key: 4, text: 'Single select'},
      {key: 5, text: 'Iteration'},
    ]
    
    const Example = () => {
      const [selectedType, setSelectedType] = React.useState()
    
      return (
        <DropdownMenu
          renderAnchor={({children, ...anchorProps}) => (
            <ButtonInvisible {...anchorProps}>
              {children} <GearIcon />
            </ButtonInvisible>
          )}
          placeholder="Field type"
          items={fieldTypes}
          selectedItem={selectedType}
          onChange={setSelectedType}
          overlayProps={{width: 'medium'}}
        />
      )
    }
    const fieldTypes = [
      {id: 0, text: 'Text'},
      {id: 1, text: 'Number'},
      {id: 3, text: 'Date'},
      {id: 4, text: 'Single select'},
      {id: 5, text: 'Iteration'},
    ]
    
    const Example = () => {
      const [selectedType, setSelectedType] = React.useState()
    
      render(
        <ActionMenu>
          <ActionMenu.Button aria-label="Select field type">{selectedType.name || 'Field type'}</ActionMenu.Button>
          <ActionMenu.Overlay width="medium">
            <ActionList selectionVariant="single">
              {fieldTypes.map(type => (
                <ActionList.Item
                  key={type.id}
                  selected={type.id === selectedType.id}
                  onSelect={() => setSelectedType(type)}
                >
                  {type.name}
                </ActionList.Item>
              ))}
            </ActionList>
          </ActionMenu.Overlay>
        </ActionMenu>,
      )
    }

    To continue to use the deprecated API for now, change the import path to @primer/react/deprecated:

    import {DropdownMenu} from '@primer/react/deprecated'

    You can use the one-time codemod to change your import statements automatically.

    drafts/DropdownMenu2

    ⚠️ DropdownMenu2 has been removed in favor of ActionMenu with ActionList

  • #1889 e9b81fae Thanks @mperrotti! -

    Label

    The Label component's API and visual design have been updated to be consistent with its counterpart in Primer ViewComponents' Label component.

    ⚠️ Major changes in the new Label component:

    • No more medium size - only small and large
    • Labels are outlined by default, so the outline prop has been removed
    • Custom text and background colors are discouraged, but still possible via the sx prop

    If you were using the Label component to render issue/PR labels, use the IssueLabelToken component instead.

    Before (v34) After (v35)
    import {Label} from '@primer/react'
    
    function Example() {
      return (
        <>
          <Label outline>default</Label>
          <Label variant="small" outline sx={{borderColor: 'danger.emphasis', color: 'danger.fg'}}>
            danger
          </Label>
        </>
      )
    }
    import {Label} from '@primer/react'
    
    function Example() {
      return (
        <>
          <Label>default</Label>
          <Label size="small" variant="danger">
            danger
          </Label>
        </>
      )
    }

    To continue to use the deprecated API for now, change the import path to @primer/react/deprecated:

    import {Label} from '@primer/react/deprecated'

    You can use the one-time codemod to change your import statements automatically.

  • #1908 61404aed Thanks @pksjce! -

    Button

    Before v35, Button was a set of seven independent components. In v35, we've simplified the Button API.

    Button variants

    We now support a variant property which takes values primary, invisible, outline and danger

    Before (v34) After (v35)
    import {ButtonPrimary, ButtonInvisible, ButtonOutline, ButtonDanger} from '@primer/react'
    
    function Example() {
      return (
        <>
          <ButtonPrimary>Primary Button</ButtonPrimary>
          <ButtonInvisible>Invisible Button</ButtonInvisible>
          <ButtonOutline>Outline Button</ButtonOutline>
          <ButtonDanger>Danger Button</ButtonDanger>
        </>
      )
    }
    import {Button} from '@primer/react'
    
    function Example() {
      return (
        <>
          <Button variant="primary">Primary Button</Button>
          <Button variant="invisible">Invisible Button</Button>
          <Button variant="outline">Outline Button</Button>
          <Button variant="danger">Danger Button</Button>
        </>
      )
    }

    Leading and trailing icons

    Previously including icons inside buttons required a lot of custom styling. In the new Button component, we now support first-class leadingIcon and trailingIcon props:

    Before (v34) After (v35)
    <Button>
      <SearchIcon />
      Search
    </Button>
    <Button leadingIcon={SearchIcon}>Search</Button>

    Icon buttons

    Icon-only buttons are common in many applications. We now have a component designed for this use-case:

    Before (v34) After (v35)
    <Button>
      <XIcon />
    </Button>
    <IconButton aria-label="Close button" icon={XIcon} />

    Size property

    Previously, we used a variant prop to set the size of buttons. We now have a prop called size which is more semantically correct.

    Before (v34) After (v35)
    <Button variant="small">Small button</Button>
    <Button size="small">Small button</Button>
  • #1900 d61b28ad Thanks @mperrotti! -

    ChoiceFieldset

    ⚠️ The CheckboxGroup and RadioGroup components are replacing the ChoiceFieldset component.

    CheckboxGroup and RadioGroup have the ability to render contextual content with your fieldset: labels, validation statuses, captions. They also handle the ARIA attributes that make the form controls accessible to assistive technology.

    Before (v34) After (v35)
    import {ChoiceFieldset} from '@primer/react'
    
    function Example() {
      return (
        <>
          {/* Multi-select */}
          <ChoiceFieldset>
            <ChoiceFieldset.Legend>Preferred Primer component interface</ChoiceFieldset.Legend>
            <ChoiceFieldset.List selectionVariant="multiple">
              <ChoiceFieldset.Item value="figma">Figma library</ChoiceFieldset.Item>
              <ChoiceFieldset.Item value="css">Primer CSS</ChoiceFieldset.Item>
              <ChoiceFieldset.Item value="react">Primer React components</ChoiceFieldset.Item>
              <ChoiceFieldset.Item value="viewcomponents">Primer ViewComponents</ChoiceFieldset.Item>
            </ChoiceFieldset.List>
          </ChoiceFieldset>
    
          {/* Single select */}
          <ChoiceFieldset>
            <ChoiceFieldset.Legend>Preferred Primer component interface</ChoiceFieldset.Legend>
            <ChoiceFieldset.List>
              <ChoiceFieldset.Item value="figma">Figma library</ChoiceFieldset.Item>
              <ChoiceFieldset.Item value="css">Primer CSS</ChoiceFieldset.Item>
              <ChoiceFieldset.Item value="react">Primer React components</ChoiceFieldset.Item>
              <ChoiceFieldset.Item value="viewcomponents">Primer ViewComponents</ChoiceFieldset.Item>
            </ChoiceFieldset.List>
          </ChoiceFieldset>
        </>
      )
    }
    import {CheckboxGroup, RadioGroup, FormControl, Checkbox, Radio} from '@primer/react'
    
    function Example() {
      return (
        <>
          {/* Multi-select */}
          <CheckboxGroup>
            <CheckboxGroup.Label>Preferred Primer component interface</CheckboxGroup.Label>
            <FormControl>
              <Checkbox value="figma" />
              <FormControl.Label>Figma</FormControl.Label>
            </FormControl>
            <FormControl>
              <Checkbox value="css" />
              <FormControl.Label>CSS</FormControl.Label>
            </FormControl>
            <FormControl>
              <Checkbox value="react" />
              <FormControl.Label>Primer React components</FormControl.Label>
            </FormControl>
            <FormControl>
              <Checkbox value="viewcomponents" />
              <FormControl.Label>Primer ViewComponents</FormControl.Label>
            </FormControl>
          </CheckboxGroup>
    
          {/* Single select */}
          <RadioGroup name="preferred-primer">
            <RadioGroup.Label>Preferred Primer component interface</RadioGroup.Label>
            <FormControl>
              <Radio value="figma" />
              <FormControl.Label>Figma</FormControl.Label>
            </FormControl>
            <FormControl>
              <Radio value="css" />
              <FormControl.Label>CSS</FormControl.Label>
            </FormControl>
            <FormControl>
              <Radio value="react" />
              <FormControl.Label>Primer React components</FormControl.Label>
            </FormControl>
            <FormControl>
              <Radio value="viewcomponents" />
              <FormControl.Label>Primer ViewComponents</FormControl.Label>
            </FormControl>
          </RadioGroup>
        </>
      )
    }

    To continue to use the deprecated API for now, change the import path to @primer/react/deprecated:

    import {ChoiceFieldset} from '@primer/react/deprecated'

    You can use the one-time codemod to change your import statements automatically.

  • #1882 df757521 Thanks @colebemis! -

    PageLayout

    PageLayout is being graduated from the drafts bundle to the main bundle.

    To upgrade, rewrite your imports accordingly:

    - import {PageLayout} from '@primer/react/drafts'
    + import {PageLayout} from '@primer/react'
  • #1888 f94dcd33 Thanks @mperrotti! -

    FormGroup, InputField, ChoiceInputField

    ⚠️ The FormControl component is replacing the FormGroup, InputField, and ChoiceInputField components. It has the ability to render contextual content with your inputs: labels, validation statuses, captions. It also handles the ARIA attributes that make the form controls accessible to assistive technology.

    Before (v34) After (v35)
    import {FormControl, Checkbox, TextInput} from '@primer/react'
    
    function Example() {
      return (
        <>
          <FormGroup>
            <FormGroup.Label htmlFor="example-text">Example text</FormGroup.Label>
            <TextInput id="example-text" />
          </FormGroup>
          {/* OR */}
          <InputField>
            <InputField.Label>Example text</InputField.Label>
            <TextInput />
          </InputField>
          {/* OR */}
          <ChoiceInputField>
            <ChoiceInputField.Label>Example text</ChoiceInputField.Label>
            <Checkbox />
          </ChoiceInputField>
        </>
      )
    }
    import {FormGroup, TextInput} from '@primer/react'
    
    function Example() {
      return (
        <>
          <FormControl>
            <FormControl.Label>Example text</FormControl.Label>
            <TextInput />
          </FormControl>
          {/* OR */}
          <FormControl>
            <FormControl.Label>Example text</FormControl.Label>
            <Checkbox />
          </FormControl>
        </>
      )
    }
    import {InputField, TextInput} from '@primer/react'
    
    function Example() {
      return (
        <InputField>
          <InputField.Label>Example text</InputField.Label>
          <TextInput />
        </InputField>
      )
    }
    import {FormControl, TextInput} from '@primer/react'
    
    function Example() {
      return (
        <FormControl>
          <FormControl.Label>Example text</FormControl.Label>
          <TextInput />
        </FormControl>
      )
    }

    To continue to use the deprecated API for now, change the import path to @primer/react/deprecated:

    import {FormGroup, ChoiceInputField, InputField} from '@primer/react/deprecated'

    You can use the one-time codemod to change your import statements automatically.

  • #1881 8cd12439 Thanks @pksjce! -

    SelectMenu

    ⚠️ SelectMenu has been deprecated. Please use ActionMenu instead.

    Before After
    <SelectMenu>
      <Button as="summary">Projects</Button>
      <SelectMenu.Modal>
        <SelectMenu.Header>Projects</SelectMenu.Header>
        <SelectMenu.List>
          <SelectMenu.Item href="#">Primer React bugs</SelectMenu.Item>
          <SelectMenu.Item href="#">Primer React roadmap</SelectMenu.Item>
          <SelectMenu.Item href="#">Project 3</SelectMenu.Item>
          <SelectMenu.Item href="#">Project 4</SelectMenu.Item>
        </SelectMenu.List>
      </SelectMenu.Modal>
    </SelectMenu>
    <ActionMenu>
      <ActionMenu.Button>Projects</ActionMenu.Button>
      <ActionMenu.Overlay>
        <ActionList showDividers>
          <ActionList.Group title="Projects">
            <ActionList.Item>Primer React bugs</ActionList.Item>
            <ActionList.Item>Primer React roadmap</ActionList.Item>
            <ActionList.Item>Project three</ActionList.Item>
            <ActionList.Item>Project four</ActionList.Item>
          </ActionList.Group>
        </ActionList>
      </ActionMenu.Overlay>
    </ActionMenu>

    See https://primer.style/react/ActionMenu for more migration examples.

    ⚠️ Dropdown has been deprecated. Please use ActionMenu instead.

    Before After
    const fieldTypes = [
      {leadingVisual: TypographyIcon, text: 'Text'},
      {leadingVisual: NumberIcon, text: 'Number'},
    ]
    
    const Example = () => {
      const [selectedItem, setSelectedItem] = React.useState()
    
      return (
        <DropdownMenu
          renderAnchor={({children, ...anchorProps}) => <ButtonInvisible {...anchorProps}>{children}</ButtonInvisible>}
          placeholder="Select a field type"
          items={fieldTypes}
          selectedItem={selectedItem}
          onChange={() => setSelectedIndex(index)}
        />
      )
    }
    const fieldTypes = [
      {icon: <TypographyIcon />, name: 'Text'},
      {icon: <NumberIcon />, name: 'Number'},
    ]
    
    const Example = () => {
      const [selectedItem, setSelectedItem] = React.useState()
    
      return (
        <ActionMenu>
          <ActionMenu.Button>{selectedItem ? selectedItem.name : 'Select a field type'}</ActionMenu.Button>
          <ActionMenu.Overlay>
            <ActionList selectionVariant="single">
              {fieldTypes.map(field => (
                <ActionList.Item onSelect={() => setSelectedItem(field)} key={field.name}>
                  <ActionList.LeadingVisual>{field.icon}</ActionList.LeadingVisual>
                  {field.name}
                </ActionList.Item>
              ))}
            </ActionList>
          </ActionMenu.Overlay>
        </ActionMenu>
      )
    }

    See https://primer.style/react/ActionMenu for more migration examples.

    Flex

    ⚠️ Flex has been deprecated. Please use Box instead.

    Before After
    <Flex flexWrap="nowrap">
      <Box p={3} color="fg.onEmphasis" bg="accent.emphasis">
        Item 1
      </Box>
    </Flex>
    <Box display="flex" flexWrap="nowrap">
      <Box p={3} color="fg.onEmphasis" bg="accent.emphasis">
        Item 1
      </Box>
    </Box>

    Grid

    ⚠️ Grid has been deprecated. Please use Box instead.

    Before After
    <Grid gridTemplateColumns="repeat(2, auto)" gridGap={3}>
      <Box p={3} color="fg.onEmphasis" bg="accent.emphasis">
        1
      </Box>
      <Box p={3} color="fg.onEmphasis" bg="attention.emphasis">
        2
      </Box>
    </Grid>
    <Box display="grid" gridTemplateColumns="repeat(2, auto)" gridGap={3}>
      <Box p={3} color="fg.onEmphasis" bg="accent.emphasis">
        1
      </Box>
      <Box p={3} color="fg.onEmphasis" bg="attention.emphasis">
        2
      </Box>
    </Box>

    BorderBox

    ⚠️ BorderBox has been deprecated. Please use Box instead.

    Before After
    <BorderBox>Item 1</BorderBox>
    <Box borderWidth="1px" borderStyle="solid" borderColor="border.default" borderRadius={2}>
      Item 1
    </Box>

    Position

    ⚠️ Position has been deprecated. Please use Box instead.

    Before After
    <>
      <Position position="absolute">...</Position>
      <Absolute>...</Absolute>
      <Relative>...</Relative>
      <Fixed>...</Fixed>
      <Sticky>...</Sticky>
    </>
    <>
      <Box position="absolute">...</Box>
      <Box position="absolute">...</Box>
      <Box position="relative">...</Box>
      <Box position="fixed">...</Box>
      <Box position="sticky">...</Box>
    </>

Minor Changes

Patch Changes

  • #1922 b1d7b8c9 Thanks @siddharthkp! - ActionMenu.Button: Fix spacing between text and caret

  • #1915 a98091c1 Thanks @siddharthkp! - - Update styles for default variant of Button's active state

    • Use active state for Button when it is used to open an Overlay
  • #1934 33da6a0e Thanks @rezrah! - Surfaced the following components and hooks from the root index:

    • Portal
    • AnchoredOverlay
    • useFocusTrap
    • useFocusZone (and types)
    • sx (and types)
    • ConfirmationDialogProps

    These exports can now be imported from the root index, rather than from their nested subfolders.

    E.g.

    - import { ConfirmationDialogProps } from '@primer/react/lib-esm/Dialog/ConfirmationDialog';
    + import { ConfirmationDialogProps } from '@primer/react';

34.7.1

Patch Changes

34.7.0

Minor Changes

  • #1862 eebb3f27 Thanks @mperrotti! - Adds CheckboxGroup and RadioGroup components to replace the ChoiceFieldset component

Patch Changes

34.6.0

Minor Changes

Patch Changes

34.5.0

Minor Changes

  • #1831 96473f39 Thanks @mperrotti! - Makes validation styling available for Select and TextInputWithTokens

  • #1836 7e8ae653 Thanks @mperrotti! - Introduces FormControl component. The FormControl component combines the functionality of InputField and ChoiceInputField, and will replace FormGroup, InputField, and ChoiceInputField.

Patch Changes

34.4.0

Minor Changes

Patch Changes

  • #1824 4eab65e5 Thanks @siddharthkp! - Overlay: Attach escape handler to overlay container instead of document to fix stopPropagation

  • #1840 1c4786c7 Thanks @jclem! - Set Node.js and npm versions to ">=12" and ">=7", respectively, in package.json manifests, and update package-lock.json files accordingly.

  • #1828 6a695bdc Thanks @siddharthkp! - ActionMenu2 + DropdownMenu2: A keyboard user will be able to wrap through options

  • #1810 35ad7084 Thanks @siddharthkp! - ActionMenu2 + DropdownMenu2: Focus the correct element when Menu is opened with keyboard. See detailed spec.

    • ArrowDown | Space | Enter: first element
    • ArrowUp: last element
  • #1842 11011f55 Thanks @jclem! - Allow KeyPaths type to accept any type in order to remove need for // @ts-ignore internally.

  • #1820 50c7bfaa Thanks @colebemis! - Add draft PageLayout component

34.3.0

Minor Changes

Patch Changes

  • #1759 493c6ea1 Thanks @siddharthkp! - AnchoredOverlay: Add support for passing an id to the anchor. Remove unnecessary aria-labelledby on anchor. ActionMenu v2: Add aria-labelledby for ActionList

  • #1779 2630800d Thanks @siddharthkp! - ActionMenu v2: ActionMenu.Button now uses Button v2

  • #1735 8ff114b1 Thanks @siddharthkp! - Add composable DropdownMenu to @primer/components/drafts

  • #1814 384c3756 Thanks @pksjce! - Upgrade @primer/behaviors

  • #1804 aa09ed79 Thanks @rezrah! - Fixes bug in PointerBox component where caret doesn't inherit correct styling. Backwards compatible with previous API.

34.2.0

Minor Changes

Patch Changes

34.1.0

Minor Changes

  • #1611 11382eeb Thanks @mperrotti! - Adds TextInputField, CheckboxInputField, and RadioInputField components. Also adds a few internal (private to primer/react) components to support form fields

Patch Changes

34.0.1

Patch Changes

34.0.0

Major Changes

  • #1676 1195336e Thanks @colebemis! - Rename npm package from @primer/components to @primer/react

    To upgrade, run:

    npm uninstall @primer/components
    npm install @primer/react

    Then update your imports:

    - import {Box} from '@primer/components'
    + import {Box} from '@primer/react'

33.1.0

Minor Changes

Patch Changes

33.0.0

Major Changes

Minor Changes

Patch Changes

  • #1668 98dc6336 Thanks @siddharthkp! - ActionList: Fix multiple selection svg by overriding global shape-rendering for github.com

  • #1596 5c6dc644 Thanks @dmarcey! - Fix alignment of items in ActionList (single-select) if some of the items have wrapping text.

  • #1538 dda6e5d7 Thanks @shiftkey! - Update typescript package to correct generated type declarations.

32.1.0

Minor Changes

Patch Changes

  • #1648 8b40a0a9 Thanks @jfuchs! - Fixed a bug with Overlay's type where DOM props were not allowed.

32.0.1

Patch Changes

32.0.0

Major Changes

Patch Changes

31.2.0

Minor Changes

  • #1544 5b55b0ab Thanks @jfuchs! - The sx prop now has types that will inform autocomplete for color and shadow values that are key paths into the theme.

  • #1517 561c0bd3 Thanks @siddharthkp! - Add experimental ActionList with composable API

Patch Changes

31.1.0

Minor Changes

  • #1523 56e2f159 Thanks @mperrotti! - Add the ability to truncate tokens in the TextInputWithToken component when the input is not focused

Patch Changes

  • #1529 da566044 Thanks @mperrotti! - Fixes a bug in TextInputWithTokens where the next token would not receive focus after the user deleted the first token using the keyboard

  • #1526 1378e771 Thanks @mperrotti! - replaces flexbox gap usage with margins

31.0.1

Patch Changes

  • #1521 28b5980c Thanks @siddharthkp! - Add trailingVisual prop to ActionList/ActionMenu. Deprecate trailingIcon and trailingText props.

31.0.0

Major Changes

Patch Changes

30.3.0

Minor Changes

30.2.1

Patch Changes

30.2.0

Minor Changes

  • #1497 b9d6a662 Thanks @jfuchs! - Updated ActionList's ItemInput type to accept DOM props for divs when renderItem is not provided

30.1.0

Minor Changes

  • #1463 bde3a034 Thanks @jfuchs! - ActionList.item accepts an as prop, allowing it to be a link, or (in combination with the renderItem prop) a Next.js or React Router link

Patch Changes

  • #1471 f1cebb7e Thanks @smockle! - Change the button which receives focus when a 'ConfirmationDialog' opens from the secondary (e.g. 'Cancel') to the primary (e.g. 'OK'). Fixes github/primer#313.

30.0.0

Major Changes

  • #1448 1a39fb02 Thanks @SferaDev! - Remove .Breadcrumb classname from the root element of the Breadcrumbs component. This change shouldn't break anything unless you have styles, scripts, or tests that reference the .Breadcrumb classname.

  • #1468 dc15763c Thanks @jfuchs! - AvatarStack no longer accepts styled props or DOM props

Minor Changes

Patch Changes

29.1.1

Patch Changes

  • #1441 f3f5afb9 Thanks @jfuchs! - Fix type error where css is a required prop of some components by excluding storybook stories from TypeScript compilation for builds

  • #1446 b4e5287c Thanks @colebemis! - Fix filter input spacing in SelectPanel

29.1.0

Minor Changes

29.0.0

Major Changes

  • #1414 f4e1de6d Thanks @jfuchs! - Removed system props support from <TextInput> and fixed its type definition.

Minor Changes

Patch Changes

28.5.0

Minor Changes

  • #1398 e4dac575 Thanks @jfuchs! - Default portal containers created by primer are absolutely positioned at 0,0

  • #1385 5470b61b Thanks @jfuchs! - Make top and left position explicit props of Overlay handled separately from other styles

  • #1388 83b888f0 Thanks @jfuchs! - Overlay takes a portalContainerName prop. This allows overlays with an anchor inside a scrolling container to track with their anchor, so long as the specified portal is also inside that scrolling container.

28.4.0

Minor Changes

Patch Changes

  • #1372 23be0ed7 Thanks @jfuchs! - Extends DropdownMenu to allow anchorRef, open, and onOpenChange props.

  • #1386 2ea30b43 Thanks @colebemis! - Bump @primer/primitives dependency to 4.6.4

  • #1387 6b4d52da Thanks @jfuchs! - Guard against MediaQueryList.addEventListener calls where unavailable and possibly fall back to .addListener

28.3.2

Patch Changes

  • #1368 36f156a0 Thanks @dgreif! - Allow anchorRef to be passed into SelectPanel if you want to use an external anchor

28.3.1

Patch Changes

28.3.0

Minor Changes

  • #1315 85d0202b Thanks @VanAnderson! - Box now accepts all styled system props.

  • #1316 4c063317 Thanks @VanAnderson! - The following components have been deprecated in favor of the Box component:

    | Component | Replacement | | ----------- | ------------------------------------------------------------------------------------------- | | Flex | <Box display="flex"> | | Grid | <Box display="grid"> | | Position | <Box> | | Absolute | <Box position="absolute"> | | Fixed | <Box position="fixed"> | | Relative | <Box position="relative"> | | Sticky | <Box position="sticky"> | | BorderBox | <Box borderWidth="1px" borderStyle="solid" borderColor="border.primary" borderRadius={2}> |

    There is a codemod available to upgrade these components:

    • TypeScript example:

      npx jscodeshift -t node_modules/@primer/react/codemods/deprecateUtilityComponents.js
      --parser=tsx path/to/workspace/src/*.tsx
    • Babel example:

      npx jscodeshift -t node_modules/@primer/react/codemods/deprecateUtilityComponents.js
      --parser=babel path/to/workspace/src/*.tsx
  • #1336 489a718b Thanks @VanAnderson! - System props are deprecated in all components except Box. Move all system props into the sx prop instead. Example:

    - <Button mr={2}>...</Button>
    + <Button sx={{mr: 2}}>...</Button>

    There is a codemod available to migrate from system props to the sx prop:

    • TypeScript example:

      npx jscodeshift -t node_modules/@primer/react/codemods/removeSystemProps.js
      --parser=tsx path/to/workspace/src/*.tsx
    • Babel example:

      npx jscodeshift -t node_modules/@primer/react/codemods/removeSystemProps.js
      --parser=babel path/to/workspace/src/*.tsx

Patch Changes

  • #1332 ec11d7b8 Thanks @mattcosta7! - Side effects are properly declared in package.json

  • #1308 a8f3ca6d Thanks @dgreif! - Focus zones will now update active-descendant on mousemove over focusable elements. ActionList has been updated to handle direct (key press) vs indirect (mousemove, DOM change, etc.) changes to active-descendant, and will use a distinct background color for the directly activated items.

28.2.5

Patch Changes

  • #1311 6f0535df Thanks @lukewar! - Expose 'textInputProps' from the 'SelectPanel'

  • #1309 dc17a49e Thanks @colebemis! - Include all shadow variables in theme object

  • #1251 528e9a41 Thanks @VanAnderson! - Call useOnOutsideClick handlers in reverse order that they are registered, and allow propagation to stop if default is prevented or an non-outside click is detected.

  • #1312 76a38432 Thanks @smockle! - Ensure clicking an AnchoredOverlay’s trigger allows it to close without immediately reopening.

28.2.4

Patch Changes

  • #1293 1148a718 Thanks @smockle! - Restore "fix: Don’t focus first 'Item' of 'DropdownMenu' and 'SelectMenu' on open" by deferring the removal of a temporary tabIndex until focus moves within the container.

  • #1279 bb38754f Thanks @VanAnderson! - Update overlay shadows

  • #1297 5fb3683d Thanks @VanAnderson! - Bump @primer/primitives to 4.4.0

  • #1288 15207119 Thanks @dgreif! - Focus zones with an activeDescendantControl will now activate the first descendant as soon as the control element is focused, rather than waiting for an up/down arrow press. Descendants stay active until the control element is blurred. This is a breaking change to useFocusZone, but this behavior is still considered to be in alpha.

  • #1292 4b643818 Thanks @dgreif! - Bump dependencies

  • #1279 bb38754f Thanks @VanAnderson! - Update TextInput border color

28.2.3

Patch Changes

28.2.2

Patch Changes

28.2.1

Patch Changes

28.2.0

Minor Changes

  • 8368a83e #1238 Thanks @dgreif! - New sizes for Overlay and Dialog. Sizes have been changed from abbreviations to full words. xs -> xsmall, sm -> small, md -> medium, lg -> large, xl -> xlarge. The sizing for Overlay has also been updated to provide a wider range of options. The original values for Overlay were based on the needs of Dialog, but Dialog is not reliant on Overlay so they don't need to have similar sizing. This is technically a breaking change, but is being released as a minor because these components are both still in alpha status.

Patch Changes

28.1.1

Patch Changes

28.1.0

Minor Changes

Patch Changes

28.0.4

Patch Changes

28.0.3

Patch Changes

  • c63fa4b5 #1215 Thanks @dgreif! - Hide divider before ActionList.Groups with filled header

  • a9260812 #1221 Thanks @dgreif! - Improved performance for lists in ActionMenu and DropdownMenu

  • c63fa4b5 #1215 Thanks @dgreif! - Align Item description to when rendered in-line

  • c63fa4b5 #1215 Thanks @dgreif! - Allow focusZoneSettings to be passed into AnchoredOverlay

  • c63fa4b5 #1215 Thanks @dgreif! - Add selectionVariant: 'multiple' for Items. These will use a checkbox input instead of a checkmark icon for selected state

  • d78af591 #1214 Thanks @VanAnderson! - renderMenuItem in ActionMenu checks preventDefault for conditionally calling onClose

  • 4ab3d175 #1222 Thanks @dgreif! - Trap focus in AnchoredOverlay as soon as it opens, regardless of the event that triggered it to open

  • ff9ce6f1 #1217 Thanks @VanAnderson! - overlayProps passthrough from ActionMenu and DropdownMenu to AnchoredOverlay.

28.0.2

Patch Changes

  • d20a5996 #1209 Thanks @dgreif! - Allow Overlay height and width to be set through AnchoredOverlay Allow ActionList Items to supply an id instead of key Performance improvements when ActionList is not given any groups Enable focus zone as soon as AnchoredOverlay opens

  • d29741ca #1196 Thanks @dgreif! - Allow custom children in ActionItem. text and description can still be provided as a shortcut, but children is now available if you need more control over the rending of the item, without sacrificing benefits from Item by using renderItem.

  • 4c2e1a2b #1195 Thanks @VanAnderson! - Export useConfirm hook and ConfirmationDialog component from index.

  • 3c13d039 #1201 Thanks @T-Hugs! - Fix overlay position when using an AnchoredOverlay

  • c9b4db79 #1199 Thanks @VanAnderson! - Action Menu can have its open state be controlled externally.

  • 3e759e59 #1211 Thanks @VanAnderson! - Use preventDefault on AnchoredOverlay instead of stopPropagation.

  • 84e3c570 #1194 Thanks @dgreif! - Handle onAction for DropdownMenu Items

  • 7aeb53fe #1200 Thanks @dgreif! - Perform ActionMenu actions after overlay has closed. This allows the action to move focus if so desired, without the ActionMenu focus trap preventing focus from moving away.

  • bba66fdd #1206 Thanks @VanAnderson! - stopPropagation for mousedown and click in AnchoredOverlay based components

28.0.1

Patch Changes

28.0.0

Major Changes

  • 5f85394d #1157 Thanks @dgreif! - Removed useMouseIntent in favor of :focus-visible. With the removal of useMouseIntent, the intent-mouse class will no longer be added to the <body>. Since :focus-visible is a relatively new psuedo-class, a polyfill is included. Any focused elements that meet the criteria for :focus-visible will also have a focus-visible class added to them by the polyfill.

Patch Changes

27.0.0

Major Changes

  • db478205 #1147 Thanks @colebemis! - Type definitions are now being generated by TypeScript instead of manually maintained. These new type definitions may differ from the previous type definitions and cause breaking changes. If you experience any new TypeScript errors, feel free to create an issue or reach out in Slack (#design-systems).

    Breaking changes

    • The following types are no longer exported:

      BaseProps
      UseDetailsProps
      AnchoredPositionHookSettings
      AnchorAlignment
      AnchorSide
      PositionSettings
      PaginationHrefBuilder
      PaginationPageChangeCallback
      PositionComponentProps
    • Props are now defined with types instead of interfaces which means in some cases you may not be able to create interfaces that extend them. To work around this issue, you may need to convert your interfaces to types:

      import {BoxProps} from '@primer/react'
      
      - interface MyFancyBox extends BoxProps {...}
      + type MyFancyBox = BoxProps & {...}
    • Some components now expect more specific ref types. For example:

      - const ref = React.useRef<HTMLElement>(null)
      + const ref = React.useRef<HTMLButtonElement>(null)
      
      return <Button ref={ref}>...</Button>

26.0.0

Major Changes

  • 016a273f #1115 Thanks @VanAnderson! - Removes deprecated presentational theme variables in favor of functional variables for styling components that are consistent across multiple themes.

    Migration guide

    If you don't use any color-related system props (e.g. color, bg, borderColor), all components should work without changes. If you're using color-related system props, you'll need to update them to use the new functional variables. Reference the tables below to see how old variables map to new functional variables.

    If you have any questions, feel free to reach out in the #design-systems channel.

    Text

    | v25 | v26 | | ------------------------ | ------------------------ | | color="text.gray" | color="text.secondary" | | color="text.grayLight" | color="text.tertiary" | | color="text.grayDark" | color="text.primary" | | color="text.red" | color="text.danger" | | color="text.white" | color="text.inverse" | | color="gray.6" | color="text.secondary" | | color="gray.5" | color="text.tertiary" | | color="gray.9" | color="text.primary" | | color="red.6" | color="text.danger" | | color="white" | color="text.inverse" | | color="blue.5" | color="text.link" | | color="gray.4" | color="text.disabled" | | color="green.5" | color="text.success" | | color="yellow.8" | color="text.warning" |

    Icon

    | v25 | v25 | | ------------------ | ------------------------ | | color="gray.9" | color="icon.primary" | | color="gray.6" | color="icon.secondary" | | color="gray.4" | color="icon.tertiary" | | color="blue.5" | color="icon.info" | | color="red.5" | color="icon.danger" | | color="green.6" | color="icon.success" | | color="yellow.8" | color="icon.warning" |

    Border

    | v25 | v26 | | --------------------------------- | ------------------------------- | | borderColor="border.blue" | borderColor="border.info" | | borderColor="border.blueLight" | n/a | | borderColor="border.grayLight" | borderColor="border.primary" | | borderColor="border.grayDark" | borderColor="border.tertiary" | | borderColor="border.grayDarker" | n/a | | borderColor="border.green" | borderColor="border.success" | | borderColor="border.greenLight" | n/a | | borderColor="border.purple" | n/a | | borderColor="border.red" | borderColor="border.danger" | | borderColor="border.redLight" | n/a | | borderColor="border.white" | borderColor="border.inverse" | | borderColor="border.whiteFace" | n/a | | borderColor="border.yellow" | borderColor="border.warning" | | borderColor="border.blackFade" | borderColor="fade.fg15" | | borderColor="border.whiteFade" | borderCOlor="fade.white15" | | borderColor="blue.5" | borderColor="border.info" | | borderColor="gray.2" | borderColor="border.primary" | | borderColor="gray.3" | borderColor="border.tertiary" | | borderColor="green.4" | borderColor="border.success" | | borderColor="red.5" | borderColor="border.danger" | | borderColor="white" | borderColor="border.inverse" |

    Background

    | v25 | v26 | | ------------------- | ------------------------ | | bg="white" | bg="bg.primary" | | bg="bg.grayLight" | bg="bg.secondary" | | bg="bg.gray" | bg="bg.tertiary" | | bg="bg.grayDark" | bg="bg.canvasInverse" | | bg="blue.0" | bg="bg.info" | | bg="blue.5" | bg="bg.infoInverse" | | bg="red.0" | bg="bg.danger" | | bg="red.5" | bg="bg.dangerInverse" | | bg="green.1" | bg="bg.success" | | bg="green.5" | bg="bg.successInverse" |

    Labels

    Note the change in pluralization from 'labels' to 'label'.

    | v25 | v26 | | ----------------------------- | ------------------------------------- | | color="labels.grayDarkText" | color="label.primary.text | | borderColor="labels.gray" | borderColor="label.primary.border | | color="labels.grayText" | color="label.secondary.text | | borderColor="labels.gray" | borderColor="label.secondary.border | | color="labels.blueText" | color="label.info.text | | borderColor="labels.blue" | borderColor="label.info.border | | color="labels.greenText" | color="label.success.text | | borderColor="labels.green" | borderColor="label.success.border | | color="labels.yellowText" | color="label.warning.text | | borderColor="labels.yellow" | borderColor="label.warning.border | | color="labels.redText" | color="label.danger.text | | borderColor="labels.red" | borderColor="label.danger.border | | color="labels.orangeText" | color="label.primary.text | | borderColor="labels.orange" | borderColor="label.primary.text | | color="labels.pinkText" | n/a | | borderColor="labels.pink" | n/a | | color="labels.purpleText" | n/a | | borderColor="labels.purple" | n/a |

    Counters

    | v25 | v26 | | --------------------- | -------------------- | | scheme="gray" | scheme="primary" | | scheme="gray-light" | scheme="secondary" |

    Timeline

    | v25 | v26 | | ----------------------------------------- | ----------------------------- | | bg="red.5" | bg="prState.closed.bg" | | bg="green.5" | bg="prState.open.bg" | | bg="purple.5" | bg="prState.merged.bg" | | bg="gray.5" | bg="prState.draft.bg" | | color="white" (context: closed PR icon) | color="prState.closed.text" | | color="white" (context: open PR icon) | color="prState.open.text" | | color="white" (context: merged PR icon) | color="prState.merged.text" | | color="white" (context: merged PR icon) | color="prState.draft.text" |

25.0.0

Major Changes

  • 8799f74a #1112 Thanks @colebemis! - Primer React now supports color modes! 🎉

    See the new Theming documentation for more details.

    Breaking changes

    • You'll need to replace the ThemeProvider from styled-components with the new Primer React ThemeProvider:
    - import {ThemeProvider} from 'styled-components'
    - import {theme} from '@primer/react
    + import {ThemeProvider} from '@primer/react'
    
    function App() {
      return (
    -   <ThemeProvider theme={theme}>
    +   <ThemeProvider>
          <div>your app here...</div>
        </ThemeProvider>
      )
    }
    • The structure of the theme object has changed to support color schemes:
    const theme = {
    - colors,
    - shadows,
    + colorSchemes: {
    +   light: {
    +     colors,
    +     shadows,
    +   },
    +   dark: {...},
    +   dark_dimmed: {...},
    + },
      space,
      fonts,
      fontSizes,
      fontWeights,
      lineHeights,
      borderWidths,
      radii,
      breakpoints,
      sizes,
    }
    • The theme.colors and theme.shadows objects are no longer available from the theme export. Use the useThemehook instead:
    - import {theme} from '@primer/react'
    + import {useTheme} from '@primer/react'
    
    function Example() {
    + const {theme} = useTheme()
      const myColor = theme.colors.text.primary
      ...
    }

Patch Changes

24.0.0

Major Changes

  • b9d9d245 #1068 Thanks @colebemis! - Remove propTypes in favor of TypeScript types

  • beef075e #1094 Thanks @colebemis! - Components no longer have a default theme prop. To ensure components still render correctly, you'll need pass the Primer theme to a styled-components <ThemeProvider> at the root of your application:

    import {ThemeProvider} from 'styled-components'
    import {theme} from '@primer/react'
    
    function App(props) {
      return (
        <div>
          <ThemeProvider theme={theme}>
            <div>your app here</div>
          </ThemeProvider>
        </div>
      )
    }

Patch Changes

23.2.1

Patch Changes

  • a42162c0 #1087 Thanks @emplums! - Fix up styles in TabNav allowing for items positioned on the right end of TabNav

23.2.0

Minor Changes

Patch Changes

23.1.0

Minor Changes

Patch Changes

23.0.4

Patch Changes

23.0.3

Patch Changes

23.0.2

Patch Changes