calcite-design-system icon indicating copy to clipboard operation
calcite-design-system copied to clipboard

Allow for Segmented Control to Display Icon Only

Open apfister opened this issue 2 years ago • 13 comments

Description

Allow for the Segmented Control (and item?) display an icon only, without having to specify text.

In the image below, I'd like only the icons to be displayed: image

Acceptance Criteria

maybe iconOnly as a property? or just display only the icon if that's the only thing specified.

Relevant Info

No response

Which Component

Segmented Control / Segmented Control Item

Example Use Case

No response

Esri team

N/A

apfister avatar Feb 02 '23 00:02 apfister

This one is on my list as well. Thanks for filing this, @apfister.

ashetland avatar Feb 06 '23 19:02 ashetland

+1 We need a simple 'multiple options' toggle and a segmented-control would have been a nice option as we wouldn't need to manage having only one option selected and reacting to just one selection event. Having multiple calcite-actions works, but its a lot of unnecessary work if the segmented-control had an iconOnly option.

image

jgrayson-apl avatar Mar 07 '23 22:03 jgrayson-apl

Would be a nice add. We can probably do as we do with button, etc., and adjust padding when only an icon property is provided.

macandcheese avatar Mar 08 '23 02:03 macandcheese

This use case also surfaced in a Community thread on 5/18, in which the use case is to display icons without text in the component.

Use case below.

geospatialem avatar May 19 '23 01:05 geospatialem

Here is my use case. The icons would be sufficient and use much less horizontal space. image

tsellste avatar May 19 '23 15:05 tsellste

Figma file ready for this update.

ashetland avatar Aug 18 '23 17:08 ashetland

cc @geospatialem, @brittneytewks

github-actions[bot] avatar Aug 18 '23 17:08 github-actions[bot]

To achieve this, we'll need to prevent using value as the displayed text when there is no slotted text, and update the padding for icon-start/end to center visually within the container. Probably a similar hasText internal state like Button has to determine a conditionally applied class, etc.

macandcheese avatar Jan 29 '24 21:01 macandcheese

@macandcheese Added a text-disabled property to opt-into this behavior as using the value as a label is a feature and is also used in other components (e.g., calcite-option).

While working on this, I also found using icons instead of text for the label could be a potential workaround (see codepen).

jcfranco avatar May 09 '24 23:05 jcfranco

Since it has icon-start/end, is the workaround workflow possibly confusing? I suppose text-disabled might also be confusing because there's no text prop like Action? Does the value prop play a role in displayed text? I believe the idea was to make value required, but if no text is in the default slot and an icon prop is used, we'd get the same end result.

ashetland avatar May 10 '24 15:05 ashetland

Since it has icon-start/end, is the workaround workflow possibly confusing?

How do you mean?

I suppose text-disabled might also be confusing because there's no text prop like Action?

We already use textDisabled w/o a matching text prop in navigation-user.

I believe the idea was to make value required, but if no text is in the default slot and an icon prop is used, we'd get the same end result.

OK, so I tracked down the behavior I called out in my earlier comment and it looks like using value as the fallback label is intentional, but there is no explicit spec for it in the original issue, PR nor documentation. It's sort of an outlier and also breaks if there's any whitespace. Also, value might not be the best option for a user-friendly label (e.g., casing, localization). For these reasons, I think it's safe to drop to simplify the behavior w/o it constituting a breaking change.

jcfranco avatar May 10 '24 17:05 jcfranco

Thanks for the catch, @ashetland! I'll make the appropriate adjustments.

jcfranco avatar May 10 '24 17:05 jcfranco

Installed and assigned for verification.

github-actions[bot] avatar May 13 '24 18:05 github-actions[bot]

🍡 Verified locally on main

DitwanP avatar May 21 '24 19:05 DitwanP