Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For individual CSS files and animation settings, use [configuration](https://web
- [Color system](https://webview-native-ui.com/projects/ionic-theme-md3/docs/color-system) — Ionic palette defaults, optional Material roles and component color assignments.
- [Android Settings appearance](https://webview-native-ui.com/projects/ionic-theme-md3/docs/android-settings) — default geometry, CSS font defaults and Ionic customization.
- [Using ion-item-group](https://webview-native-ui.com/projects/ionic-theme-md3/docs/using-ion-item-group) — shared inset-list markup for iOS 27 and MD3.
- [Special markup](https://webview-native-ui.com/projects/ionic-theme-md3/docs/special-markup) — opt-in component combinations used by the demo.
- [Special markup](https://webview-native-ui.com/projects/ionic-theme-md3/docs/special-markup) — opt-in patterns, including connected button groups with `ion-segment.segment-group`.
- [ESLint](https://webview-native-ui.com/projects/ionic-theme-md3/docs/eslint) — check list structure with ESLint rules.
- [Migration](https://webview-native-ui.com/projects/ionic-theme-md3/docs/migration) — optional setup simplification and version-specific upgrade steps.

Expand Down
Binary file modified demo/e2e/screenshot.spec.ts-snapshots/device-segment-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/e2e/screenshot.spec.ts-snapshots/device-segment-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/e2e/screenshot.spec.ts-snapshots/segment-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/e2e/screenshot.spec.ts-snapshots/segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion demo/src/app/docs/docs-content.generated.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion demo/src/app/docs/docs-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('DocsPage', () => {
expect(element.querySelector('article.docs-content h1')?.textContent).toContain('Special markup');
expect(element.querySelectorAll('.code-block-container pre.shiki code').length).toBeGreaterThan(0);
expect(element.querySelector('.code-block-container code span[style*="color"]')).not.toBeNull();
expect(element.querySelectorAll('figure.docs-example').length).toBe(8);
expect(element.querySelectorAll('figure.docs-example').length).toBe(9);
expect(element.querySelectorAll('figure.docs-example ion-segment.segment-group > ion-segment-button').length).toBe(3);
});
});
6 changes: 6 additions & 0 deletions demo/src/app/index/pages/segment/segment.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,11 @@ <h2>segment</h2>
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<h2>Connected button group</h2>
<ion-segment class="segment-group" value="week" aria-label="Calendar view">
<ion-segment-button value="day"><ion-label>Day</ion-label></ion-segment-button>
<ion-segment-button value="week"><ion-label>Week</ion-label></ion-segment-button>
<ion-segment-button value="month"><ion-label>Month</ion-label></ion-segment-button>
</ion-segment>
</section>
</ion-content>
18 changes: 18 additions & 0 deletions docs/special-markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ same Android appearance without an additional effect or JavaScript helper.
Explicit Ionic colors, disabled state, and `fill="clear"` / `fill="outline"` keep their
normal meaning. The class does not force a different fill.

## Connected button groups

Add `.segment-group` to an `ion-segment` to present related choices as a Material 3
connected button group. Ionic manages the value, keyboard navigation and disabled
state. Pressing a button tightens its inner corners and starts an Ionic ripple at the touch point. On release,
the selected button takes a pill shape. Button widths and the gaps between them
stay fixed throughout the interaction, as in Android 17’s Transit volume settings.

```html preview
<ion-segment class="segment-group" value="week" aria-label="Calendar view">
<ion-segment-button value="day"><ion-label>Day</ion-label></ion-segment-button>
<ion-segment-button value="week"><ion-label>Week</ion-label></ion-segment-button>
<ion-segment-button value="month"><ion-label>Month</ion-label></ion-segment-button>
</ion-segment>
```

[Material 3 button groups](https://m3.material.io/components/button-groups/overview)

## Toolbar button badges

Place `ion-badge` directly inside an `ion-button` in an `ion-toolbar`. Both
Expand Down
74 changes: 74 additions & 0 deletions src/styles/components/ion-segment.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,81 @@
@use '../utils/colors' as md3;

ion-segment.md:not(.md3-disabled) {
border-bottom: 1px solid
var(
--ion-item-border-color,
var(--ion-border-color, var(--ion-color-step-150, var(--ion-background-color-step-150, rgba(0, 0, 0, 0.13))))
);
}

ion-segment.md.segment-group:not(.md3-disabled) {
gap: 2px;
border-bottom: 0;

> ion-segment-button.md:not(.md3-disabled) {
--md3-segment-inner-corner: 8px;
--indicator-height: 0;
--background: transparent;
--background-checked: transparent;
--color: #{md3.color(on-secondary-container)};
--color-checked: #{md3.color(on-secondary)};
--md3-segment-selected-background: #{md3.color(secondary)};
--background-hover: currentColor;
--background-focused: currentColor;
--ripple-color: currentColor;
min-width: 48px;
min-height: 48px;
padding-block: 4px;
text-transform: none;
letter-spacing: 0.006em;

&.in-segment-color {
--md3-segment-selected-background: var(--ion-color-base);
--color-checked: var(--ion-color-contrast);
}
&:first-of-type {
--md3-segment-start-corner: 20px;
}
&:last-of-type {
--md3-segment-end-corner: 20px;
}
&.segment-button-checked {
--md3-segment-inner-corner: 20px;
}
&:active {
--md3-segment-inner-corner: 4px;
}
&::part(native) {
min-height: 40px;
border-start-start-radius: var(--md3-segment-start-corner, var(--md3-segment-inner-corner));
border-end-start-radius: var(--md3-segment-start-corner, var(--md3-segment-inner-corner));
border-start-end-radius: var(--md3-segment-end-corner, var(--md3-segment-inner-corner));
border-end-end-radius: var(--md3-segment-end-corner, var(--md3-segment-inner-corner));
background: #{md3.color(secondary-container)};
color: var(--color);
}
&.segment-button-checked::part(native) {
background: var(--md3-segment-selected-background);
color: var(--color-checked);
}
&.ion-focused::part(native) {
outline: 2px solid currentColor;
outline-offset: -3px;
}
> ion-label:not(.md3-disabled),
> ion-icon:not(.md3-disabled) {
margin-block: 0;
}
> ion-icon:not(.md3-disabled) {
font-size: 18px;
}

@media (prefers-reduced-motion: no-preference) {
&::part(native) {
transition:
border-radius var(--token-expressive-fast-effects),
background-color var(--token-expressive-fast-effects);
}
}
}
}
Loading