Adding a "pressed" prop for buttons

Hello,

I’m trying to port my rich text field editor to the new Polaris components. The new tooltip and popover (I’ve found them while reading the minified code) are awesome, great work on that, I love how you guys embraced the new standards (including the interestFor) for that.

I found a missing feature though with the button component. I’d like to convey a “pressed” state where the button is active:

For instance here I’d like to give the bold button a pressed state similar to what Shopify is doing:

Is there any way to add that?

Thanks!

@Anthony_Frehner do you think this could be added? :slight_smile: For now the only workaround I’ve found is to use the secondary variant as an “active” state, but it’s not wonderful, visually speaking:

Hey @bakura10, this can be achieved with the s-clickable if you change the background from base to strong.

There is a nice example in polarisblocks

I really like the editor you are building, are you using anything like Lexical behind the scene? Does it support markdown?

Anyway, a pressed state would be much easier to handle this kind of stuff.

I used this approach for tabs, however, I had to set a custom font-size at 0.8rem as the s-paragraph and s-text is bigger than the font-size is a s-button.

Here is the result.

Thank you!

Thanks! I thought of this but I would prefer to use a button (I feel it is better for accessibility as those are really buttons) but I’ll fallback to s-clickable.

For the text editor, it is just for managing rich text field metafields. It is a not a complete RTE editor. You can use it here: GitHub - maestrooo/rich-text-field: A Shopify Polaris components to manage rich text field metafields.

Clickable is a decent workaround for now, as we actually render it as a button element in the shadow dom anyway.

I believe we have plans on supporting this type of component in the future.

Thanks @bakura10! Nice work on the rich-text-field. Too bad is built directly in React and we can’t use it, but is a nice piece of inspiration.