@@ -108,6 +108,54 @@ class Tabs extends BaseComponent {
108108 'paramName ' => 'tab ' ,
109109 );
110110
111+ /**
112+ * CSS class for the main tabs wrapper element.
113+ *
114+ * @since 4.0.0
115+ * @var string
116+ */
117+ protected string $ wrapper_class = '' ;
118+
119+ /**
120+ * CSS class for the tab list container.
121+ *
122+ * @since 4.0.0
123+ * @var string
124+ */
125+ protected string $ tab_list_class = '' ;
126+
127+ /**
128+ * CSS class applied to each tab button element.
129+ *
130+ * @since 4.0.0
131+ * @var string
132+ */
133+ protected string $ tab_button_class = '' ;
134+
135+ /**
136+ * CSS class for the inner content wrapper inside a tab button
137+ *
138+ * @since 4.0.0
139+ * @var string
140+ */
141+ protected string $ tab_button_content_class = '' ;
142+
143+ /**
144+ * CSS class for the tab label text.
145+ *
146+ * @since 4.0.0
147+ * @var string
148+ */
149+ protected string $ tab_label_class = '' ;
150+
151+ /**
152+ * CSS class for the sub-label text.
153+ *
154+ * @since 4.0.0
155+ * @var string
156+ */
157+ protected string $ tab_sub_label_class = '' ;
158+
111159 /**
112160 * Set the tab data.
113161 *
@@ -172,6 +220,101 @@ public function url_params( array $params ) {
172220 return $ this ;
173221 }
174222
223+ /**
224+ * Set the CSS class for the main tabs wrapper element.
225+ *
226+ * @since 4.0.0
227+ *
228+ * @param string $wrapper_class CSS class name(s) for the wrapper.
229+ * @return $this
230+ */
231+ public function wrapper_class ( string $ wrapper_class ) {
232+
233+ $ this ->wrapper_class = ! empty ( $ wrapper_class )
234+ ? sprintf ( ' class="%s" ' , esc_attr ( $ wrapper_class ) )
235+ : '' ;
236+
237+ return $ this ;
238+ }
239+
240+
241+ /**
242+ * Set the CSS class for the tab list container.
243+ *
244+ * @since 4.0.0
245+ *
246+ * @param string $tab_list_class CSS class name(s) for the tab list.
247+ * @return $this
248+ */
249+ public function tab_list_class ( string $ tab_list_class ) {
250+
251+ $ this ->tab_list_class = esc_attr ( $ tab_list_class );
252+
253+ return $ this ;
254+ }
255+
256+
257+ /**
258+ * Set the CSS class for each tab button element.
259+ *
260+ * @since 4.0.0
261+ *
262+ * @param string $tab_button_class CSS class name(s) for the tab button.
263+ * @return $this
264+ */
265+ public function tab_button_class ( string $ tab_button_class ) {
266+ $ this ->tab_button_class = ! empty ( $ tab_button_class )
267+ ? sprintf ( ' class="%s" ' , esc_attr ( $ tab_button_class ) )
268+ : '' ;
269+ return $ this ;
270+ }
271+
272+ /**
273+ * Set the CSS class for the inner content wrapper inside a tab button.
274+ *
275+ * @since 4.0.0
276+ *
277+ * @param string $tab_button_content_class CSS class name(s) for the tab button content.
278+ * @return $this
279+ */
280+ public function tab_button_content_class ( string $ tab_button_content_class ) {
281+ $ this ->tab_button_content_class = ! empty ( $ tab_button_content_class )
282+ ? sprintf ( ' class="%s" ' , esc_attr ( $ tab_button_content_class ) )
283+ : '' ;
284+ return $ this ;
285+ }
286+
287+ /**
288+ * Set the CSS class for the tab label text.
289+ *
290+ * @since 4.0.0
291+ *
292+ * @param string $tab_label_class CSS class name(s) for the tab label.
293+ * @return $this
294+ */
295+ public function tab_label_class ( string $ tab_label_class ) {
296+ $ this ->tab_label_class = ! empty ( $ tab_label_class )
297+ ? sprintf ( ' class="%s" ' , esc_attr ( $ tab_label_class ) )
298+ : '' ;
299+ return $ this ;
300+ }
301+
302+
303+ /**
304+ * Set the CSS class for the tab sub-label text.
305+ *
306+ * @since 4.0.0
307+ *
308+ * @param string $tab_sub_label_class CSS class name(s) for the tab sub-label.
309+ * @return $this
310+ */
311+ public function tab_sub_label_class ( string $ tab_sub_label_class ) {
312+ $ this ->tab_sub_label_class = ! empty ( $ tab_sub_label_class )
313+ ? sprintf ( ' class="%s" ' , esc_attr ( $ tab_sub_label_class ) )
314+ : '' ;
315+ return $ this ;
316+ }
317+
175318 /**
176319 * Get the tabs component.
177320 *
@@ -194,8 +337,9 @@ public function get(): string {
194337 defaultTab: "<?php echo $ default ; // phpcs:ignore ?> ",
195338 urlParams: <?php echo $ url_params ; // phpcs:ignore ?>
196339 })'
340+ <?php echo $ this ->wrapper_class ; // phpcs:ignore ?>
197341 >
198- <div x-ref="tablist" class="tutor-tabs-nav" role="tablist" aria-orientation="<?php echo $ orientation ; // phpcs:ignore ?> ">
342+ <div x-ref="tablist" class="tutor-tabs-nav <?php echo $ this -> tab_list_class ; ?> " role="tablist" aria-orientation="<?php echo $ orientation ; // phpcs:ignore ?> ">
199343 <template x-for="tab in tabs" :key="tab.id">
200344 <button
201345 type="button"
@@ -204,11 +348,17 @@ public function get(): string {
204348 x-bind:aria-selected="isActive(tab.id)"
205349 :disabled="tab.disabled ? true : false"
206350 @click="selectTab(tab.id)"
351+ <?php echo $ this ->tab_button_class ; // phpcs:ignore ?>
207352 >
208353 <template x-if="tab.icon">
209354 <span x-data="tutorIcon({ name: tab.icon, width: 24, height: 24 })"></span>
210355 </template>
211- <span x-text="tab.label"></span>
356+
357+ <div <?php echo $ this ->tab_button_content_class ; //phpcs:ignore ?> >
358+ <span x-text="tab.label" <?php echo $ this ->tab_label_class ; //phpcs:ignore ?> ></span>
359+ <span x-text="tab.sub_label" <?php echo $ this ->tab_sub_label_class ; //phpcs:ignore ?> ></span>
360+ </div>
361+
212362 </button>
213363 </template>
214364 </div>
0 commit comments