Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This creates a much needed IconButton component with four variants:
ghost
,outline
,soft
, andsolid
. @eakbulut would very much appreciate your feedback! There were some decisions made without an obvious right answer.Zero-offset outline focus ring
I chose to make the outline variant's focus ring share the button's outline. For example:
TailwindUI's canonical outline button does the same thing; but Catalyst UI (also created by the Tailwind Team), does not 🤷. I favored reusing the outline because it's easier to implement and I thought it still looked good. But it's slightly inconsistent, because other elements focus rings are 2px offset from the component. If removing the offset is undesirable then we can implement another way.
Icon scaling
I chose to make the icon scale with the component size. This seemed to be the least brittle approach because it works with any button size. However, I don't know if it's the best approach from a visual POV. It didn't seem bad to me so I kept it. TailwindUI's examples don't scale the icon in an IconButton though. For example:
Skeleton button supports colors and icons
I chose to make the skeleton state very flexible by allowing developers to customize the color and icon. I suspect that if one is using a skeleton in the first place, that they don't know what the color or icon ought to be. Otherwise, they'd just show that. That being said, this allows them the option of having a more specific or less specific skeleton. It's probably easier to see what I mean by experimenting with Storybook's controls.
Notes:
I chose to control aspects of the component with CSS classes instead of React properties wherever possible. For example, making the button a circle is just done by passing in
rounded-full
. Similarly, controlling the size is done by passing insize-x
.The toggle button is very similar to this component but I'll hold off on updating it until we nail this one down.