Skip to content

fix(accordion): update styles for ionic theme#31023

Open
OS-susmitabhowmik wants to merge 26 commits intonextfrom
ROU-11979-fix-accordian-styles
Open

fix(accordion): update styles for ionic theme#31023
OS-susmitabhowmik wants to merge 26 commits intonextfrom
ROU-11979-fix-accordian-styles

Conversation

@OS-susmitabhowmik
Copy link

@OS-susmitabhowmik OS-susmitabhowmik commented Mar 19, 2026

Issue number: resolves internal


What is the current behavior?

There were several issues in the ionic theme which are resolved in this PR:

  • The last item of an accordion had a divider
  • The pressed state color did not match design specifications
  • Nested accordions did not have not have horizontal padding, causing the focus state to be different from the parent accordion

What is the new behavior?

The following changes were made in the ionic theme:

  • Removed the divider from the final accordion item
  • Update the pressed state color to match design specifications
  • Add additional horizontal padding for nested accordion items

Does this introduce a breaking change?

  • Yes
  • No

Other information

@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Mar 24, 2026 10:40pm

Request Review

@github-actions github-actions bot added the package: core @ionic/core package label Mar 19, 2026
@OS-susmitabhowmik OS-susmitabhowmik added type: bug a confirmed bug report and removed package: core @ionic/core package labels Mar 19, 2026
@OS-susmitabhowmik OS-susmitabhowmik changed the title fix(accordion): Remove last item divider, update pressed state background color, and add header padding for ionic theme fix(accordion): remove last item divider, update pressed state background color, and add header padding for ionic theme Mar 19, 2026
Comment on lines +126 to +131
// Item in Accordion
// --------------------------------------------------
// Ensure button element in accordion header has proper horizontal padding specifically for nested accordions
:host(.accordion-header-item) .item-native {
@include globals.padding-horizontal(globals.$ion-space-400);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style doesn't seem to be applied. I commend this out locally and the tests still passed. After inspecting the element, this is already being applied through the slot styles.

Regardless, any padding changes must be done through the slot styles that I linked.

Suggested change
// Item in Accordion
// --------------------------------------------------
// Ensure button element in accordion header has proper horizontal padding specifically for nested accordions
:host(.accordion-header-item) .item-native {
@include globals.padding-horizontal(globals.$ion-space-400);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's applied within nested accordions so that the padding of the child accordions match the padding for the parent. The slot styles don't seem to work as expected, I think perhaps because the nested accordion items are within the shadow DOM. Removing these styles and class removes the horizontal padding for the nested items leading to inconsistencies in the focus styles between the parent and children. I also don't think we previously had tests for nested accordions with the ionic theme, I included them as a part of this commit a3a76f1.

Screenshot 2026-03-23 at 5 57 01 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the goal is to line up the nested accordion header items, then we can simply update the following code to:

ion-accordion > [slot="content"] ion-item {
  @include globals.typography(globals.$ion-body-md-regular);

  color: globals.$ion-primitives-neutral-1000;

-   --padding-start: 0;
  --padding-top: #{globals.$ion-space-300};
  --padding-bottom: #{globals.$ion-space-300};
-  --padding-end: 0;
  --min-height: #{globals.$ion-scale-700};
}

+ ion-accordion > [slot="content"] ion-item:not([slot="header"]) {
+  --padding-start: 0;
+  --padding-end: 0;
+ }

I was able to get the same result, I verified by running tests locally and they all pass.

Make sure to restart the server if you're running it else it doesn't apply the changes within the core styles.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thetaPC, this works! I updated the styles and removed the additional class in this commit ee059a1

Comment on lines +203 to +208

/**
* Add a class to identify this item as an accordion header
* for specific styling purposes
*/
ionItem.classList.add('accordion-header-item');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed based on my comment.

Suggested change
/**
* Add a class to identify this item as an accordion header
* for specific styling purposes
*/
ionItem.classList.add('accordion-header-item');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't think we can remove this class as it breaks the styling for nested accordions. Please see my comment here but I am happy to try any alternative suggestions!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to remove this ee059a1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes can be reverted based on my comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied above (#31023 (comment)), but I think we may need to keep the new class.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed ee059a1

@thetaPC
Copy link
Contributor

thetaPC commented Mar 23, 2026

@OS-susmitabhowmik Also please update the PR title to be shorter, thanks!

@OS-susmitabhowmik OS-susmitabhowmik changed the title fix(accordion): remove last item divider, update pressed state background color, and add header padding for ionic theme fix(accordion): update styles for ionic theme Mar 24, 2026
@OS-susmitabhowmik
Copy link
Author

@OS-susmitabhowmik Also please update the PR title to be shorter, thanks!

@thetaPC Updated!

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based off my reply, this can be done without adding a class after testing it locally. Please let me know if I'm misunderstanding the issue.

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package type: bug a confirmed bug report

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants