This has already been put into practice in v35. While we haven't deleted any deprecated component yet, all of the other recommendations are working out just fine for us and our consumers. We have both /drafts
and /deprecated
paths setup for import and for documentation. LGTM 👍
Pinned
Activity
pksjce merge to primer/react
pksjce wants to merge primer/react
Fix ButtonGroup component and add docs
Summary
- Fixes layout bug with ButtonGroup by changing the
display
property frominline-block
toinline-flex
- Adds docs for ButtonGroup component
Closes https://github.com/primer/react/issues/1978
Screenshots
Before
After
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
Do you think this requires a more descriptive change-log? It might affect existing implementations and people may not be sure why those are failing?
pksjce merge to primer/react
Fix ButtonGroup component and add docs
Summary
- Fixes layout bug with ButtonGroup by changing the
display
property frominline-block
toinline-flex
- Adds docs for ButtonGroup component
Closes https://github.com/primer/react/issues/1978
Screenshots
Before
After
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce merge to primer/react
Fix ButtonGroup component and add docs
Summary
- Fixes layout bug with ButtonGroup by changing the
display
property frominline-block
toinline-flex
- Adds docs for ButtonGroup component
Closes https://github.com/primer/react/issues/1978
Screenshots
Before
After
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce issue comment primer/react
[WIP] Replace UnderlineNav component
Describe your changes here.
This PR implements new version of UnderlineNav as per https://github.com/github/primer/issues/892
Why is this work being done? The current UnderlineNav is outdated and not adequate in the following ways.
- Uses css class names. These clash with existing implementations.
- Not accessible as it doesnt set
aria-label
andaria-current-page
. - Does not support icons
- Has no support for smaller screens
My proposal with this PR is
- We can keep the existing API for
UnderlineNav
while changing all of its internals and adding new API for icons and accessibility - No deprecation and drafts required.
- Refer to https://primer.style/view-components/components/alpha/underlinenav/#
Pending things to merge this PR.
- Accessibility updates. Add label and current page
- Add actions - Ability to add buttons?
- Allow right align of the nav
- Sophisticated links
- Add tests and types
- Add documentation
Closes https://github.com/github/primer/issues/892
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
Working on making a responsive UnderlineNav
- Add
overflow
prop as per discussion with design - Add context to store child widths
- Create
useNavResponsive
(maybe change this name) for managing container width.
pksjce push primer/react
commit sha: 47c9c626911563e925fa3245b8bf3badb31744b6
push time in 1 week agopksjce merge to primer/react
Select component a11y fixes
These changes address the feedback from @alliethu in this comment (repo only visible internally)
Closes https://github.com/github/primer/issues/540
Merge checklist
- Added/updated tests
- [n/a] Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce merge to primer/react
Select component a11y fixes
These changes address the feedback from @alliethu in this comment (repo only visible internally)
Closes https://github.com/github/primer/issues/540
Merge checklist
- Added/updated tests
- [n/a] Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce wants to merge primer/react
Select component a11y fixes
These changes address the feedback from @alliethu in this comment (repo only visible internally)
Closes https://github.com/github/primer/issues/540
Merge checklist
- Added/updated tests
- [n/a] Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
wow thanks for the comments explaining why!
pksjce issue comment primer/react
[WIP] Replace UnderlineNav component
Describe your changes here.
This PR implements new version of UnderlineNav as per https://github.com/github/primer/issues/892
Why is this work being done? The current UnderlineNav is outdated and not adequate in the following ways.
- Uses css class names. These clash with existing implementations.
- Not accessible as it doesnt set
aria-label
andaria-current-page
. - Does not support icons
- Has no support for smaller screens
My proposal with this PR is
- We can keep the existing API for
UnderlineNav
while changing all of its internals and adding new API for icons and accessibility - No deprecation and drafts required.
- Refer to https://primer.style/view-components/components/alpha/underlinenav/#
Pending things to merge this PR.
- Accessibility updates. Add label and current page
- Add actions - Ability to add buttons?
- Allow right align of the nav
- Sophisticated links
- Add tests and types
- Add documentation
Closes https://github.com/github/primer/issues/892
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
Here's a loom of me demo-ing what's possible with the new implementation of UnderlineNav
https://www.loom.com/share/0a5432ffced946c5901109882e045b8d
pksjce wants to merge primer/react
[WIP] Replace UnderlineNav component
Describe your changes here.
This PR implements new version of UnderlineNav as per https://github.com/github/primer/issues/892
Why is this work being done? The current UnderlineNav is outdated and not adequate in the following ways.
- Uses css class names. These clash with existing implementations.
- Not accessible as it doesnt set
aria-label
andaria-current-page
. - Does not support icons
- Has no support for smaller screens
My proposal with this PR is
- We can keep the existing API for
UnderlineNav
while changing all of its internals and adding new API for icons and accessibility - No deprecation and drafts required.
- Refer to https://primer.style/view-components/components/alpha/underlinenav/#
Pending things to merge this PR.
- Accessibility updates. Add label and current page
- Add actions - Ability to add buttons?
- Allow right align of the nav
- Sophisticated links
- Add tests and types
- Add documentation
Closes https://github.com/github/primer/issues/892
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
I'm not sure. whats the alternative? It doesn't seem to work without the get.
pksjce merge to primer/react
[WIP] Replace UnderlineNav component
Describe your changes here.
This PR implements new version of UnderlineNav as per https://github.com/github/primer/issues/892
Why is this work being done? The current UnderlineNav is outdated and not adequate in the following ways.
- Uses css class names. These clash with existing implementations.
- Not accessible as it doesnt set
aria-label
andaria-current-page
. - Does not support icons
- Has no support for smaller screens
My proposal with this PR is
- We can keep the existing API for
UnderlineNav
while changing all of its internals and adding new API for icons and accessibility - No deprecation and drafts required.
- Refer to https://primer.style/view-components/components/alpha/underlinenav/#
Pending things to merge this PR.
- Accessibility updates. Add label and current page
- Add actions - Ability to add buttons?
- Allow right align of the nav
- Sophisticated links
- Add tests and types
- Add documentation
Closes https://github.com/github/primer/issues/892
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce push primer/react
commit sha: bb741c05593b6fc63c17e16af2d832e1122f0c58
push time in 1 month agopksjce push primer/react
commit sha: a7c77f6adaea2ece28e0c8b78d927d80fbeaa1d6
push time in 1 month agopksjce issue comment primer/react
Accessible `IconButton` with label viewable as `Tooltip`
Summary
There is no documented example of how to render an icon-only button with an accessible tooltip in a way that would meet all of the following standard requirements:
- Render as an icon-only button with a single focus target
- Read the label one time in a manner that ties it to the button, for screen reader users
- Show the label on hover, for mouse users
- Show the label on focus, for keyboard users
If this is a supported behavior, then some documentation is needed to show how to do it. If this is not supported, it would be very useful functionality to add to Primer.
The IconButton
documentation provides an example of how to label the component in an accessible manner:
<IconButton aria-label="Search" icon={SearchIcon} />
And the Tooltip
documentation has the same:
<Tooltip aria-label="Hello, Tooltip!">Text with a tooltip</Tooltip>
Both of these examples use aria-label
however, which provides no obvious way to create an icon button that shows its accessible label on hover as a tooltip.
Use Cases
This is a very common requirement. See for example these instances on github.com:
Notifications bell:
Markdown editor toolbar:
Code view:
This is recommended as a best practice by Primer's own tooltip guide:
Attempts
I've tried all of the following examples but I haven't been able to find a satisfying way to do this:
Label on tooltip: Tooltip does not appear on button focus and the button appears as unlabelled in the accessibility tree.
<Tooltip aria-label="Bold">
<IconButton icon={BoldIcon} />
</Tooltip>
Label on button only: Tooltip does not work at all.
<Tooltip>
<IconButton icon={BoldIcon} aria-label="Bold" />
</Tooltip>
Label on both: The label will be read twice to screen readers (something like "Tooltip: Bold, Button: Bold") which is unnecessarily redundant. Also the tooltip still doesn't appear on focus.
<Tooltip aria-label="Bold">
<IconButton icon={BoldIcon} aria-label="Bold" />
</Tooltip>
Tooltip as button: Seems like a promising idea but Tooltip
does not support the as
prop.
<Tooltip aria-label="Bold" as={IconButton} icon={BoldIcon} />
Button as tooltip: Renders an unfocuseable span
instead of a button
.
<IconButton icon={BoldIcon} as={Tooltip} aria-label="Bold" />
Tooltip in button children: Does not work because the IconButton
ignores children.
<IconButton icon={BoldIcon} aria-label="Bold">
<Tooltip aria-label="Bold" role="presentation">Bold</Tooltip>
</IconButton>
Tooltip as button icon: This is horribly inelegant, but it does generate a good accessibility tree and still shows the tooltip on hover. It unfortunately still doesn't show the tooltip on focus, but it's the best I have for now.
<IconButton
icon={() => <Tooltip aria-label="Bold" role="presentation"><BoldIcon /></Tooltip>}
aria-label="Bold"
/>
Proposed Solution
My ideal solution would be to just show the IconButton
's aria-label
as a tooltip by default.
To configure this, I propose adding two new props to the IconButton
component:
-
disableTooltip
: Turn off the tooltip. -
tooltipProps
: Configure the tooltip by passing props to the underlyingTooltip
component.
Then I could achieve my goal simply with:
<IconButton icon={BoldIcon} aria-label="Bold" />
Love this discussion.
First off, I agree with @khiga8 that the label and the tooltip content must be separate entities. They both have different functions. Label is an immediate quick recognition of the button's functionality while the tooltip is an elaborate context driven description. If the tooltip text is going to be the same as the button label text, that is not an appropriate use of the tooltip.
Additionally, providing a default tooltip with the button is not a great idea. This leads to unnecessary API overload on the Button like tooltipProps
and hideTooltip
. We want to use something like hideTooltip
sparingly but with this pattern it might become a norm than an escape hatch.
My vote is for the Tooltip
component to intentionally wrap around the IconButton
when a tooltip is required. This can then become a consistent pattern for all Tooltip
usage. For example, it's not uncommon to have tooltips on normal Button
components, Input
, Link
components etc as shown here.
So in the simple use case we have
<Tooltip
text="Add bold text"
direction="sw"
>
<IconButton icon={BoldIcon} label="Bold" />
</Tooltip>
Further, we should have additional API for Tooltip to separate the trigger and rendered content to support more complex usecases like components in tooltips and dynamically rendered tooltips.
import {Key} from '@primer/react'
import * from '@primer/react/tooltip'
<Tooltip direction="sw">
<TooltipTrigger>
<IconButton icon={BoldIcon} label="Bold" />
</TooltipTrigger>
<TooltipContent>
<>Add bold text, <Key meta>B</Key></>
</TooltipContent>
</Tooltip>
pksjce push primer/react
commit sha: 0f27ee816a253ea4fb3d891d32c2c628ea2a7702
push time in 1 month agopksjce push primer/react
commit sha: 375da5552320fd373f100bf2dfe1dd27f02e3d92
push time in 1 month agopksjce pull request primer/react
Replace UnderlineNav component
Describe your changes here.
This PR implements new version of UnderlineNav as per https://github.com/github/primer/issues/892
Why is this work being done? The current UnderlineNav is outdated and not adequate in the following ways.
- Uses css class names. These clash with existing implementations.
- Not accessible as it doesnt set
aria-label
andaria-current-page
. - Does not support icons
- Has no support for smaller screens
My proposal with this PR is
- We can keep the existing API for
UnderlineNav
while changing all of its internals and adding new API for icons and accessibility - No deprecation and drafts required.
- Refer to https://primer.style/view-components/components/alpha/underlinenav/#
Pending things to merge this PR.
- Accessibility updates. Add label and current page
- Add actions - Ability to add buttons?
- Allow right align of the nav
- Sophisticated links
- Add tests and types
- Add documentation
Closes https://github.com/github/primer/issues/892
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce push primer/react
commit sha: a8b3ed16e59c40c45ff4843df491838afb6931a1
push time in 1 month agopksjce pull request primer/react
Add button focus styles
In anticipation of Button
s accessibility review, I'm pulling in changes from https://github.com/primer/css/pull/1744/files for button specific focus.
My reference is to the focus styles in this storybook. https://primer-css-eyj5rcc1n-primer.vercel.app/css/storybook?path=/story/patterns-focusstyles--focus-styles
The main change is to remove focus styles of box-shadow
and substitute it with outline
. primary
variant of the button gets some special treatment but all others have same focus styles.
Before
After

Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
pksjce push primer/react
commit sha: 2f436be520e4ceecb9906046f6d3367758e49f82
push time in 1 month agopksjce push primer/react
commit sha: a8f29a8d51b3d7dba17d370ee5810c43f5364f8f
push time in 1 month agopksjce push primer/react
commit sha: 40b318acd4a96f1a189d4feac1812bffa4efdcdf
push time in 1 month agopksjce push primer/react
commit sha: 54e89a2133942f78d704c80f36c9e7641f8dbaf3
push time in 1 month agopksjce issue comment primer/react
Add button focus styles
In anticipation of Button
s accessibility review, I'm pulling in changes from https://github.com/primer/css/pull/1744/files for button specific focus.
My reference is to the focus styles in this storybook. https://primer-css-eyj5rcc1n-primer.vercel.app/css/storybook?path=/story/patterns-focusstyles--focus-styles
The main change is to remove focus styles of box-shadow
and substitute it with outline
. primary
variant of the button gets some special treatment but all others have same focus styles.
Before
After

Merge checklist
- Added/updated tests
- Added/updated documentation
- Tested in Chrome
- Tested in Firefox
- Tested in Safari
- Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
Hey @mperrotti - It seems to be working fine on Safari now that I've updated it.
https://user-images.githubusercontent.com/417268/162121462-4c16ab32-6d4c-4606-bfd0-5a5114d7e014.mov
pksjce merge to primer/react
Add plugin to find source code from storybook
Adds a way of jumping from storybook to source code
📺 As seen on design sync: https://github.rewatch.com/video/1cqzuowd7jt5a0ee-di-design-sync-march-31-2022?t=482
pksjce issue comment primer/react
Add plugin to find source code from storybook
Adds a way of jumping from storybook to source code
📺 As seen on design sync: https://github.rewatch.com/video/1cqzuowd7jt5a0ee-di-design-sync-march-31-2022?t=482
Super cool! So Alt+click to open the code? Is there better discoverability of the shortcut?
ADR: Parallel drafts track & plan for deprecated components - DEADLINE: 13 MAY 2022
Read the rendered markdown
Context: As we work on maturity of our components, we will sometimes need to deprecate components that are replaced with new components. Here's something to start that conversation and converge on a strategy.
tl;dr: We should detangle "drafts" from component lifecycle.
1. RenameExperimental
toCandidate
in Component maturity lifecycle: Candidate, Alpha, Beta and Stable.2. Renamedrafts
toexperimental
. A component can havebeta
maturity in theexperimental
bundle.(scrapped the above 2 suggestions for the churn they'll cause in the ecosystem, see this comment for more context. We do have the optional of changing
drafts
tonext
orlabs
if that's more descriptive) 3. Draft components should not be collocated with "main bundle" components in the documentation or status page. They should have their own section, as draft components are not recommended as an alternative yet.Flowchart:
📺 Here's a video of a dry run of the flowchart: https://github.rewatch.com/video/arc9fb2sivdkm44j-draft-parallel-track-dry-run
Code example for the stages: