Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react, svelte, solid): Add wrapperClass property #6254

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 7 additions & 0 deletions src/react/swiper-react.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ interface SwiperProps extends SwiperOptions {
*/
wrapperTag?: string;

/**
* CSS class name of slides' wrapper
*
* @default 'swiper-wrapper'
*/
wrapperClass?: string;

/**
* Get Swiper instance
*/
Expand Down
3 changes: 2 additions & 1 deletion src/react/swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Swiper = forwardRef(
className,
tag: Tag = 'div',
wrapperTag: WrapperTag = 'div',
wrapperClass = 'swiper-wrapper',
children,
onSwiper,
...rest
Expand Down Expand Up @@ -205,7 +206,7 @@ const Swiper = forwardRef(
>
<SwiperContext.Provider value={swiperRef.current}>
{slots['container-start']}
<WrapperTag className="swiper-wrapper">
<WrapperTag className={uniqueClasses(wrapperClass)}>
{slots['wrapper-start']}
{renderSlides()}
{slots['wrapper-end']}
Expand Down
7 changes: 7 additions & 0 deletions src/solid/swiper-solid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ interface SwiperProps extends SwiperOptions {
*/
wrapperTag?: string;

/**
* CSS class name of slides' wrapper
*
* @default 'swiper-wrapper'
*/
wrapperClass?: string;

/**
* Get Swiper instance
*/
Expand Down
3 changes: 2 additions & 1 deletion src/solid/swiper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const Swiper = (props) => {
'ref',
'tag',
'wrapperTag',
'wrapperClass',
]);

const params = createMemo(() => getParams(rest));
Expand Down Expand Up @@ -221,7 +222,7 @@ const Swiper = (props) => {
<SwiperContext.Provider value={swiperRef}>
{slidesSlots().slots['container-start']}

<div class="swiper-wrapper">
<div class={uniqueClasses(local.wrapperClass)}>
{slidesSlots().slots['wrapper-start']}
{renderSlides()}
{slidesSlots().slots['wrapper-end']}
Expand Down
3 changes: 2 additions & 1 deletion src/svelte/swiper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

export let tag = 'div';
export let wrapperTag = 'div';
export let wrapperClass = 'swiper-wrapper';

let containerClasses = 'swiper';
let breakpointChanged = false;
Expand Down Expand Up @@ -158,7 +159,7 @@
{...restProps}
>
<slot name="container-start" />
<svelte:element this={wrapperTag} class="swiper-wrapper">
<svelte:element this={wrapperTag} class={uniqueClasses(wrapperClass)}>
<slot name="wrapper-start" />
<slot {virtualData} />
<slot name="wrapper-end" />
Expand Down