diff --git a/src/lib/components/Accordion/Accordion.spec.tsx b/src/lib/components/Accordion/Accordion.spec.tsx
index 7a6ad3aff..a3919d44c 100644
--- a/src/lib/components/Accordion/Accordion.spec.tsx
+++ b/src/lib/components/Accordion/Accordion.spec.tsx
@@ -115,7 +115,9 @@ describe('Components / Accordion', () => {
it('should use custom `base` classes', () => {
const theme = {
accordion: {
- base: 'text-4xl',
+ root: {
+ base: 'text-4xl',
+ },
},
};
@@ -131,9 +133,11 @@ describe('Components / Accordion', () => {
it('should use custom `flush` classes', () => {
const theme = {
accordion: {
- flush: {
- off: 'text-4xl',
- on: 'text-3xl',
+ root: {
+ flush: {
+ off: 'text-4xl',
+ on: 'text-3xl',
+ },
},
},
};
diff --git a/src/lib/components/Accordion/Accordion.tsx b/src/lib/components/Accordion/Accordion.tsx
index 3f85513cf..a0d7f17d8 100644
--- a/src/lib/components/Accordion/Accordion.tsx
+++ b/src/lib/components/Accordion/Accordion.tsx
@@ -2,32 +2,24 @@ import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren, ReactElement } from 'react';
import { Children, cloneElement, useMemo, useState } from 'react';
import { HiChevronDown } from 'react-icons/hi';
+import { DeepPartial } from '..';
+import { mergeDeep } from '../../helpers/mergeDeep';
import { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';
-import { AccordionContent } from './AccordionContent';
+import { AccordionContent, FlowbiteAccordionComponentTheme } from './AccordionContent';
import type { AccordionPanelProps } from './AccordionPanel';
import { AccordionPanel } from './AccordionPanel';
-import { AccordionTitle } from './AccordionTitle';
+import { AccordionTitle, FlowbiteAccordionTitleTheme } from './AccordionTitle';
export interface FlowbiteAccordionTheme {
+ root: FlowbiteAccordionRootTheme;
+ content: FlowbiteAccordionComponentTheme;
+ title: FlowbiteAccordionTitleTheme;
+}
+
+export interface FlowbiteAccordionRootTheme {
base: string;
- content: {
- base: string;
- };
flush: FlowbiteBoolean;
- title: {
- arrow: {
- base: string;
- open: {
- off: string;
- on: string;
- };
- };
- base: string;
- flush: FlowbiteBoolean;
- heading: string;
- open: FlowbiteBoolean;
- };
}
export interface AccordionProps extends PropsWithChildren
> {
@@ -36,6 +28,7 @@ export interface AccordionProps extends PropsWithChildren>
children: ReactElement | ReactElement[];
flush?: boolean;
collapseAll?: boolean;
+ theme?: DeepPartial;
}
const AccordionComponent: FC = ({
@@ -45,6 +38,7 @@ const AccordionComponent: FC = ({
flush = false,
collapseAll = false,
className,
+ theme: customTheme = {},
...props
}): JSX.Element => {
const [isOpen, setOpen] = useState(collapseAll ? -1 : 0);
@@ -55,7 +49,8 @@ const AccordionComponent: FC = ({
),
[alwaysOpen, arrowIcon, children, flush, isOpen],
);
- const theme = useTheme().theme.accordion;
+
+ const theme = mergeDeep(useTheme().theme.accordion.root, customTheme);
return (
> = ({ children, className, ...props }): JSX.Element => {
+export interface FlowbiteAccordionComponentTheme {
+ base: string;
+}
+
+export interface AccordionContentProps extends PropsWithChildren
> {
+ theme?: DeepPartial;
+}
+
+export const AccordionContent: FC = ({
+ children,
+ className,
+ theme: customTheme = {},
+ ...props
+}): JSX.Element => {
const { isOpen } = useAccordionContext();
- const theme = useTheme().theme.accordion.content;
+
+ const theme = mergeDeep(useTheme().theme.accordion.content, customTheme);
return (
{
arrowIcon?: FC
>;
as?: FlowbiteHeadingLevel;
+ theme?: DeepPartial;
}
export const AccordionTitle: FC = ({
as: Heading = 'h2',
children,
className,
+ theme: customTheme = {},
...props
}): JSX.Element => {
const { arrowIcon: ArrowIcon, flush, isOpen, setOpen } = useAccordionContext();
- const theme = useTheme().theme.accordion.title;
-
const onClick = () => typeof setOpen !== 'undefined' && setOpen();
+ const theme = mergeDeep(useTheme().theme.accordion.title, customTheme);
+
return (