﻿WEBVTT

00:00:00.226 --> 00:00:01.240
<v David>Hi everyone!

00:00:01.265 --> 00:00:04.664
In today's video, we'll be
taking a look at toggle switches

00:00:04.718 --> 00:00:08.726
and how we can create a simple
content switcher in WordPress.

00:00:09.078 --> 00:00:11.189
We'll be using some code snippets,

00:00:11.236 --> 00:00:15.728
and it will work in Elementor, in
Bricks or any page builder of your choice.

00:00:16.400 --> 00:00:17.913
Let's go ahead and see some examples.

00:00:18.886 --> 00:00:21.753
Here are a few examples of toggle switches
that you may come across.

00:00:22.200 --> 00:00:24.518
The first one is a dark mode switcher

00:00:25.292 --> 00:00:28.166
and that just switches
the dark mode on or off.

00:00:29.325 --> 00:00:33.341
Then we have another kind of toggle switch,
this one that is the most common one.

00:00:33.818 --> 00:00:36.533
And that just switches something
on or off.

00:00:36.694 --> 00:00:39.787
So it can switch like your reduce motion,

00:00:39.812 --> 00:00:42.333
you say I want to switch
reduce motion on or off,

00:00:42.358 --> 00:00:45.665
or I want to switch this badge on or off.

00:00:46.251 --> 00:00:47.892
So that's another kind of switcher.

00:00:48.433 --> 00:00:54.033
And then the third type of switcher that
we know is a content switcher.

00:00:54.384 --> 00:00:59.266
And that basically toggles the content from
one type of content to the other.

00:00:59.266 --> 00:01:02.396
Something like monthly to yearly
or things like that.

00:01:03.185 --> 00:01:10.228
And when we click on it, it switches the
entire content from monthly to yearly.

00:01:10.253 --> 00:01:12.521
So this is the monthly

00:01:12.545 --> 00:01:14.545
and this is the yearly price.

00:01:15.646 --> 00:01:18.271
As with most things in web design,

00:01:18.303 --> 00:01:20.959
there are a number of ways
to create toggle switches.

00:01:21.467 --> 00:01:24.322
And I would like you to ask yourself
some questions

00:01:24.376 --> 00:01:27.103
to guide you through which method
you'd want to take.

00:01:27.962 --> 00:01:29.575
So the first question is:

00:01:29.599 --> 00:01:32.719
How many logical properties are you
going to switch between?

00:01:33.188 --> 00:01:36.266
So are you switching just
one thing on or off?

00:01:37.000 --> 00:01:38.968
Or are you switching between two things?

00:01:39.633 --> 00:01:43.109
Or are you switching between
multiple things?

00:01:43.554 --> 00:01:46.733
That can give you an idea of
which method to take.

00:01:48.021 --> 00:01:50.178
If you're only concerned with one thing,

00:01:50.224 --> 00:01:52.887
that is you're switching one
thing on or off.

00:01:52.912 --> 00:01:56.666
Like your dark mode, you're switching
the dark mode on or off.

00:01:57.283 --> 00:02:01.599
Or things like reduce motion, a toggle to
switch reduce motion on or off.

00:02:02.322 --> 00:02:04.633
Or your play button to switch it on or off.

00:02:05.092 --> 00:02:08.201
Then you might want to consider using
the toggle switch pattern.

00:02:08.959 --> 00:02:11.631
So that can be done in one of two ways.

00:02:11.656 --> 00:02:14.234
You can either use the checkbox

00:02:14.259 --> 00:02:19.066
or you use a button with some
ARIA information attached to it.

00:02:19.820 --> 00:02:21.646
I'll leave a link to it in the description.

00:02:22.418 --> 00:02:26.285
On the other hand, if you're switching
between two completely different things,

00:02:26.945 --> 00:02:29.774
that is not just an on or off
kind of situation,

00:02:30.103 --> 00:02:32.677
then you might want to consider
the toggle switch pattern,

00:02:32.927 --> 00:02:36.138
which I'll show now, and that
uses radio buttons.

00:02:36.474 --> 00:02:41.947
So I'll say, if the radio button
is A, then show A.

00:02:41.985 --> 00:02:44.418
If the radio button is B, then show B.

00:02:44.937 --> 00:02:46.470
So that is the second pattern.

00:02:46.626 --> 00:02:48.703
On the other hand, if you
have more than two things

00:02:48.728 --> 00:02:50.056
that you want to toggle between,

00:02:50.099 --> 00:02:53.373
then I'll just say, use a tab
pattern for that.

00:02:53.398 --> 00:02:57.818
There are tabs are good enough to
toggle between three things

00:02:57.857 --> 00:03:01.098
because it will get a bit more complicated
if you try to do something else.

00:03:01.153 --> 00:03:05.387
So just stick with the tab pattern
if it is more than two items.

00:03:06.098 --> 00:03:10.866
So in this video, I'm just going to show
you how to do a toggle switch pattern,

00:03:11.032 --> 00:03:12.672
which switches between two things.

00:03:13.266 --> 00:03:14.586
But before we do that,

00:03:14.611 --> 00:03:18.258
we'll go ahead and do a keyboard
test with what we have currently

00:03:18.290 --> 00:03:23.166
and a screen reader test to see how
everything should look and sound like.

00:03:23.724 --> 00:03:24.764
So now let's jump back in.

00:03:25.317 --> 00:03:28.051
So for the first one, you can
see when I click on it,

00:03:29.000 --> 00:03:33.118
it has the focus outline and you
see some action going on.

00:03:34.126 --> 00:03:37.808
Then if I use the keyboard, so if
I tab to it, so tab key,

00:03:37.833 --> 00:03:40.199
you see it has the focus outline as well.

00:03:40.199 --> 00:03:44.288
And I press the space bar, it toggles
between the both states.

00:03:45.358 --> 00:03:48.566
One other important thing you
need to remember is that

00:03:49.067 --> 00:03:52.621
you cannot toggle both the states
and the visible text.

00:03:53.082 --> 00:03:56.519
Make sure if you are
toggling the name,

00:03:56.544 --> 00:03:59.156
that is the label or the
visible text or the ARIA label,

00:03:59.758 --> 00:04:02.303
then make sure you're
not toggling the state,

00:04:02.328 --> 00:04:06.203
which is like the aria-checked or
aria-pressed or something like that.

00:04:06.247 --> 00:04:09.104
Because if you toggle both of
them at the same time,

00:04:09.128 --> 00:04:11.475
then it will cause some problems
for screen readers.

00:04:11.506 --> 00:04:16.074
So usually you toggle either the
state or the visible text.

00:04:16.607 --> 00:04:18.607
Don't toggle both of them together.

00:04:19.604 --> 00:04:22.505
So this is for the first one.
If I tab to the next thing,

00:04:23.512 --> 00:04:28.573
you can see we have the
focus outline on the toggle switch.

00:04:28.599 --> 00:04:33.237
And when I press the space bar,
it toggles it on and off.

00:04:34.308 --> 00:04:36.874
And you can see all of the animation,
everything is there.

00:04:38.117 --> 00:04:44.333
Then we can come down to the last switch,
same thing, space bar, on or off.

00:04:45.365 --> 00:04:48.588
You can also use the arrow keys
as well to do on or off.

00:04:49.885 --> 00:04:52.408
And everything works with the keyboard.

00:04:52.729 --> 00:04:54.799
We'll also do a screen reader test now

00:04:54.824 --> 00:04:57.743
to see how it might sound to a
screen reader user.

00:04:59.185 --> 00:05:01.368
So I'll turn on NVDA.

00:05:02.000 --> 00:05:04.986
NVDA is free for Windows.
You can go ahead and download it.

00:05:05.066 --> 00:05:07.870
If you are a Mac user, then
you have VoiceOver,

00:05:07.895 --> 00:05:11.522
which is free and comes as default
with all Mac books.

00:05:12.507 --> 00:05:14.804
So now I'll turn on NVDA.

00:05:17.495 --> 00:05:19.941
<v NVDA>Task bar, toggle buttons.

00:05:20.550 --> 00:05:21.613
<v David>Okay.

00:05:21.638 --> 00:05:24.524
<v NVDA>Different content…toggle buttons,

00:05:24.548 --> 00:05:26.845
banner landmark, navigation landmark,

00:05:26.869 --> 00:05:30.266
main landmark, different content
switchers heading level one.

00:05:30.266 --> 00:05:34.547
<v David>So if I press the tab key, it will now
go to the focus able elements now.

00:05:34.601 --> 00:05:37.023
<v David>So that's</v> 
<v NVDA>toggle dark mode switch off.</v>

00:05:37.805 --> 00:05:39.637
<v David>So you see toggle dark mode.

00:05:40.005 --> 00:05:41.278
It told me the switch is off.

00:05:41.303 --> 00:05:44.017
That means the dark mode has
been switched off.

00:05:44.042 --> 00:05:46.159
If I press the space bar.
<v NVDA>- On.

00:05:46.184 --> 00:05:47.370
<v David>It tells me it's on.

00:05:47.395 --> 00:05:49.573
So that means I've turned
on the dark mode.

00:05:50.088 --> 00:05:52.485
So that's one thing you can listen to.

00:05:52.510 --> 00:05:56.188
Next one is the switcher.

00:05:56.213 --> 00:05:57.357
So you see, if I tab into…

00:05:57.382 --> 00:06:00.883
<v NVDA>Try any of the snippets below grouping
add sale badge switch off.

00:06:01.391 --> 00:06:08.745
So because I'm using semantic elements,
it read out the name of the grouping,

00:06:08.770 --> 00:06:11.288
which is the label for all of
the different switches.

00:06:11.687 --> 00:06:15.272
It also read out the name
of the individual switch itself,

00:06:15.297 --> 00:06:16.945
which says add sale badge.

00:06:17.953 --> 00:06:19.717
And then it told me it is off.

00:06:19.742 --> 00:06:21.815
The moment I press space bar.
<v NVDA>On.</v>

00:06:21.841 --> 00:06:22.841
<v David>It tells me it's on.

00:06:22.866 --> 00:06:25.799
You can listen to it again if
I press the Shift-Tab.

00:06:25.824 --> 00:06:28.033
<v NVDA>Buy now link.
<v David>And then press the tab key again.</v>

00:06:28.033 --> 00:06:31.759
<v NVDA>Try any of the snippets below grouping
add sale badge switch on.

00:06:31.833 --> 00:06:35.470
<v David>So you see, it tells me the entire label.

00:06:35.495 --> 00:06:37.157
It reads everything to me.

00:06:37.212 --> 00:06:39.487
And I can now press the space bar.
<v NVDA>Off.</v>

00:06:39.958 --> 00:06:42.041
<v NVDA>- On. Off.</v>
<v David>- On or off.</v>

00:06:42.066 --> 00:06:43.533
And that's it for this switcher

00:06:43.533 --> 00:06:46.333
<v NVDA>Screen reader voice

00:06:47.073 --> 00:06:51.599
<v David>And the reason for that is because this
is a simple toggle on or off.

00:06:52.380 --> 00:06:57.974
But in terms of the content toggle,
where we are toggling content.

00:06:57.999 --> 00:06:59.623
So we are saying monthly to yearly.

00:06:59.648 --> 00:07:01.861
It's not just an on off situation.

00:07:01.886 --> 00:07:06.448
It is more of a more informative way.

00:07:06.473 --> 00:07:12.024
Then for that one, we use radio buttons,
not checkboxes or buttons.

00:07:12.063 --> 00:07:14.360
So watch what happens when I come here.

00:07:14.385 --> 00:07:15.930
<v NVDA>Main landmark.

00:07:15.955 --> 00:07:20.343
Try any of the snippets below grouping view
add code snippet screenshot link.

00:07:21.015 --> 00:07:22.124
<v David>Okay. Then

00:07:22.149 --> 00:07:26.433
<v NVDA>Select your billing cycle grouping.
Monthly radio button checked one of two.

00:07:26.933 --> 00:07:28.792
<v David>It says monthly video button.

00:07:28.823 --> 00:07:30.876
Let me go ahead and press the space bar.

00:07:30.901 --> 00:07:33.133
<v NVDA>Yearly radio button checked two of two.

00:07:33.133 --> 00:07:36.323
<v David>It says yearly radio button
checked two of two.

00:07:36.363 --> 00:07:38.197
So it tells me if I press
the space bar again.

00:07:38.222 --> 00:07:40.413
<v NVDA>Monthly radio button checked one of two.

00:07:40.632 --> 00:07:44.008
<v David>And because you have radio buttons, that
means the arrow keys should work as well.

00:07:44.033 --> 00:07:47.288
So if I press the down arrow
or the right arrow.

00:07:47.313 --> 00:07:49.518
Yearly radio button checked two of two.

00:07:49.955 --> 00:07:52.190
Monthly radio button checked one of two.

00:07:52.455 --> 00:07:54.119
See, that's how all of them work.

00:07:54.144 --> 00:07:59.033
They give you every information that
you need from the radio button.

00:07:59.058 --> 00:08:00.333
It works with keyboard.

00:08:00.333 --> 00:08:01.699
It works with the screen reader.

00:08:02.033 --> 00:08:04.119
And it works with the mouse.

00:08:04.171 --> 00:08:05.737
So those are all of the things…

00:08:06.057 --> 00:08:07.486
Let me go back to the light mode.

00:08:07.854 --> 00:08:09.941
And yeah, that's it.

00:08:09.966 --> 00:08:12.960
So now let's go ahead and see
how we can easily just

00:08:12.985 --> 00:08:16.086
put the code and we get
our content switcher.

00:08:16.609 --> 00:08:19.172
So I'll jump into two different builders.

00:08:19.493 --> 00:08:21.680
First, I'll try it out with Elementor.

00:08:22.106 --> 00:08:24.701
Then I'll use it in Bricks.

00:08:24.726 --> 00:08:27.892
So to show you that it works in any
builder of your choice.

00:08:28.396 --> 00:08:29.956
So now let's jump right into Elementor.

00:08:30.628 --> 00:08:33.181
So here we are in the Elementor editor.

00:08:33.212 --> 00:08:36.649
The two things we need are
a HTML widget and

00:08:36.680 --> 00:08:38.874
the two items that we want
to toggle between.

00:08:38.899 --> 00:08:40.273
So it could be two containers.

00:08:40.298 --> 00:08:42.831
It could be two widgets or anything.

00:08:43.260 --> 00:08:47.104
And then all I have to do is drop
in the code into the HTML widget

00:08:47.129 --> 00:08:49.732
and we'll add some ID and class names

00:08:49.756 --> 00:08:53.612
to the two widgets that
we want to toggle between.

00:08:54.385 --> 00:08:57.588
So let's go ahead.
I'll drop in a container.

00:08:59.417 --> 00:09:01.463
Then I'll drop in the HTML widget.

00:09:01.987 --> 00:09:03.133
So HTML.

00:09:06.081 --> 00:09:08.599
Then I'll go ahead and paste in my HTML.

00:09:09.927 --> 00:09:11.927
Don't worry, the code
will be in the description,

00:09:11.952 --> 00:09:13.778
so you can go ahead and edit it.

00:09:14.206 --> 00:09:15.573
So we have the code.

00:09:16.021 --> 00:09:18.369
Finally, I'll drop in my two widgets.

00:09:19.244 --> 00:09:22.455
So I'll say maybe two pricing widgets.

00:09:25.056 --> 00:09:26.077
One.

00:09:26.212 --> 00:09:29.045
And then I'll just duplicate it, two.

00:09:30.279 --> 00:09:32.068
Maybe I'll make it a bit smaller.

00:09:33.240 --> 00:09:37.815
This is not needed, but I'm just going to
use it for demonstration purposes only.

00:09:43.299 --> 00:09:46.600
And then just copy, paste the style.

00:09:47.250 --> 00:09:48.283
So we have two.

00:09:49.608 --> 00:09:54.366
Then let me make it all in the centre.

00:09:54.466 --> 00:09:56.786
So that they're all lined up properly.

00:09:57.661 --> 00:10:00.005
Now, I can go ahead and…

00:10:00.030 --> 00:10:01.427
so that we know that it's working.

00:10:01.466 --> 00:10:04.942
Let me go ahead and change this
to yearly pricing.

00:10:06.847 --> 00:10:07.847
So yearly.

00:10:09.829 --> 00:10:11.251
And the other one.

00:10:12.103 --> 00:10:14.063
Or that will be monthly pricing.

00:10:18.759 --> 00:10:20.509
And the other one will be yearly pricing.

00:10:21.915 --> 00:10:24.790
So, yearly pricing.

00:10:25.947 --> 00:10:29.855
And I'll give it a price of maybe…

00:10:33.285 --> 00:10:36.383
0.99.

00:10:37.548 --> 00:10:39.017
Okay

00:10:39.500 --> 00:10:42.086
So that we have two different pricing.

00:10:42.977 --> 00:10:44.593
So let me save that.

00:10:45.557 --> 00:10:50.233
The last thing we need to do is add
some class names and some IDs.

00:10:51.186 --> 00:10:55.521
So for the first one, we'll
go to the advanced tab

00:10:55.568 --> 00:10:59.567
and we'll give it a class
name and an ID.

00:10:59.592 --> 00:11:05.076
The class name is going to be
dd-content-section.

00:11:05.741 --> 00:11:09.537
Then for the first one, 
I'll say it is active.

00:11:09.600 --> 00:11:10.983
So are the two thing—

00:11:11.008 --> 00:11:13.319
So 'dd-content-section', then 'active'.

00:11:14.092 --> 00:11:17.862
For the second one, it will only
be just 'dd-content-section'.

00:11:18.659 --> 00:11:22.135
So classes 'dd-content-section'.

00:11:22.160 --> 00:11:23.495
Immediately it hides.

00:11:24.260 --> 00:11:27.290
Then all we need to do
is now give it some IDs.

00:11:27.333 --> 00:11:36.669
So for the first one, I'll give it
an ID of 'dd-item1-content'.

00:11:37.997 --> 00:11:41.520
And for the second one, let me
pull up the navigator.

00:11:42.472 --> 00:11:43.666
Go to the second one.

00:11:44.534 --> 00:11:48.159
To open up the navigator using
your keyboard, just press Ctrl + I.

00:11:49.214 --> 00:11:50.667
So I'm going to the second one.

00:11:51.222 --> 00:11:59.023
Advanced tab and this one, the CSS ID
is 'dd-item2-content'.

00:11:59.859 --> 00:12:02.429
So 'dd-item2-content'.

00:12:02.454 --> 00:12:03.566
And that's it.

00:12:04.031 --> 00:12:05.031
Publish it.

00:12:05.672 --> 00:12:07.272
And now if you preview on the front end.

00:12:08.439 --> 00:12:09.737
See monthly pricing.

00:12:09.762 --> 00:12:11.706
If I tab through yearly pricing.

00:12:12.151 --> 00:12:13.353
And that's how simple it is.

00:12:14.229 --> 00:12:17.993
We get our toggle switch and everything
here is customizable.

00:12:18.032 --> 00:12:19.366
So let's go back to the code.

00:12:19.831 --> 00:12:21.243
We'll go to the HTML.

00:12:22.188 --> 00:12:24.466
And we can now change all of the code.

00:12:24.666 --> 00:12:27.888
So basically the things at the beginning
are the things that we change.

00:12:28.366 --> 00:12:32.535
So let me just zoom in a little bit
and try to expand this.

00:12:34.222 --> 00:12:38.297
So the things we need to change here
are, let me close the [navigator].

00:12:39.291 --> 00:12:40.991
So you see select your billing cycle.

00:12:41.391 --> 00:12:43.461
That is it here.
Select your billing cycle.

00:12:43.486 --> 00:12:44.837
That is the legend.

00:12:44.862 --> 00:12:46.470
The legend is basically the heading.

00:12:47.493 --> 00:12:51.351
And one nice thing about using
this fieldset and legend is that

00:12:51.376 --> 00:12:53.994
you can actually put your heading…

00:12:54.019 --> 00:12:59.127
So, you can actually write this as a H2
or H3 within that legend.

00:12:59.152 --> 00:13:00.833
It's allowed.
So slash H3.

00:13:01.708 --> 00:13:03.250
And that is allowed.

00:13:03.275 --> 00:13:05.109
But first let me make sure this is gone.

00:13:07.004 --> 00:13:09.766
So you can do that if you want.
But let me not do that.

00:13:15.120 --> 00:13:20.235
Then the other things there are,
you can change the label.

00:13:20.260 --> 00:13:22.766
So we are changing the legend
and then the labels.

00:13:22.766 --> 00:13:24.239
You see here it says monthly.

00:13:24.708 --> 00:13:28.308
You can say that should be, maybe we
leave that as monthly.

00:13:28.333 --> 00:13:30.653
And the other one rather than yearly,
you can see annually.

00:13:31.106 --> 00:13:33.301
So that one is here,

00:13:33.326 --> 00:13:35.839
where you see yearly, you can
now write annually.

00:13:38.284 --> 00:13:40.133
And that should update automatically

00:13:40.133 --> 00:13:42.304
because it is the label that
is being read out.

00:13:43.498 --> 00:13:48.078
So every of the different ARIA, whatever
information is on the inputs.

00:13:48.578 --> 00:13:51.795
The label is just giving the
inputs their name.

00:13:52.295 --> 00:13:56.981
But everything that has to give
the name, role and state of the input

00:13:57.006 --> 00:13:58.513
is on the input itself.

00:13:59.513 --> 00:14:00.699
So that's it.

00:14:01.340 --> 00:14:03.060
Those are the things that
we need to change.

00:14:03.085 --> 00:14:05.000
Like I said, you can change
the billing cycle.

00:14:05.000 --> 00:14:07.309
You can change the monthly and
then the annually.

00:14:07.334 --> 00:14:10.363
And finally, we have your CSS classes.

00:14:10.418 --> 00:14:14.332
This is where you define all of the
different parameters for the class.

00:14:14.357 --> 00:14:17.033
So you can change the height
of the toggle switch.

00:14:17.033 --> 00:14:18.123
You can change the width.

00:14:18.148 --> 00:14:19.581
If you want the width to be bigger.

00:14:19.899 --> 00:14:22.793
So say something like 6rem.

00:14:22.819 --> 00:14:24.211
Make it longer.

00:14:24.236 --> 00:14:25.915
But I'll just leave it at 4rem.

00:14:26.000 --> 00:14:27.192
You can use it in pixels.

00:14:27.217 --> 00:14:29.515
You can do however you want it.

00:14:29.540 --> 00:14:32.506
So all of this is what controls
everything that you see here.

00:14:32.531 --> 00:14:33.766
These are all of the colours.

00:14:33.766 --> 00:14:38.035
I just used my own CSS variable colours
to style everything.

00:14:38.723 --> 00:14:40.301
And that's it.

00:14:41.387 --> 00:14:44.684
All simple and easy to do.

00:14:46.042 --> 00:14:47.135
Let me publish it.

00:14:48.213 --> 00:14:49.766
And you can go to the front end.

00:14:50.003 --> 00:14:53.440
And see if I use the keyboard
and I press the tab key.

00:14:54.088 --> 00:14:55.333
We get our focus outline.

00:14:55.333 --> 00:14:57.186
If I press space bar, it works.

00:14:57.475 --> 00:14:59.066
The arrow keys, they work.

00:15:00.166 --> 00:15:03.533
The same principle applies when working
with Bricks Builder.

00:15:04.000 --> 00:15:05.240
Let's go ahead and take a look.

00:15:05.490 --> 00:15:07.214
So here we are in Bricks Builder.

00:15:07.574 --> 00:15:10.207
First let me go ahead and
drop in a section.

00:15:10.394 --> 00:15:11.706
Which comes with the container.

00:15:12.566 --> 00:15:15.814
Then what we need to do is now
drop in a code element.

00:15:16.126 --> 00:15:19.267
Then we'll drop in the two elements that
we want to toggle between.

00:15:19.936 --> 00:15:22.466
So I'll drop in a code element.
So code.

00:15:25.212 --> 00:15:26.935
And I'll drop in a block.

00:15:28.920 --> 00:15:29.920
Maybe two blocks.

00:15:30.240 --> 00:15:34.646
And then within these two blocks is where
the elements will reside.

00:15:35.154 --> 00:15:36.513
So let me drop in some elements.

00:15:36.979 --> 00:15:38.580
So maybe a pricing widget.

00:15:41.275 --> 00:15:42.893
And I'll duplicate that.

00:15:45.123 --> 00:15:46.313
Put that in the next block.

00:15:47.154 --> 00:15:52.975
Then within the code element is where we'll
drop in our HTML, CSS and JavaScript.

00:15:53.490 --> 00:15:56.566
Let me go ahead and make this container
to be a column.

00:15:56.566 --> 00:15:58.102
Okay. So we have everything.

00:15:58.821 --> 00:16:03.066
So for the code, first I'll drop
in all of the code.

00:16:04.378 --> 00:16:05.661
Paste it in there.

00:16:06.339 --> 00:16:09.130
Then the nice thing with Bricks

00:16:09.155 --> 00:16:12.512
is that you can now separate
your HTML, CSS and JavaScript.

00:16:12.537 --> 00:16:14.298
So I'll copy the JavaScript.

00:16:18.540 --> 00:16:22.423
And paste it within the JavaScript
area without the script tags.

00:16:22.448 --> 00:16:24.133
So I'll delete the script tag.

00:16:25.138 --> 00:16:26.513
Go to the top.

00:16:26.538 --> 00:16:29.740
And delete the script tag as
well as the style tag.

00:16:31.255 --> 00:16:33.056
Then I'll copy all of the CSS.

00:16:40.430 --> 00:16:41.539
Cut that.

00:16:41.564 --> 00:16:42.849
Deletes the style tag.

00:16:43.943 --> 00:16:45.990
And paste it within the CSS area.

00:16:47.068 --> 00:16:51.037
So we have the HTML, the CSS,
and the JavaScript.

00:16:51.822 --> 00:16:54.166
Next, we want to make sure that everything
is being loaded.

00:16:54.205 --> 00:16:55.947
So I'll say execute code.

00:16:57.338 --> 00:16:59.833
Then we don't really have
any dynamic data.

00:16:59.833 --> 00:17:01.473
So we don't need to pass
any dynamic data.

00:17:01.983 --> 00:17:04.319
And let's say I want to render
without wrapper.

00:17:06.123 --> 00:17:07.623
Then I will sign the code.

00:17:09.819 --> 00:17:12.354
And we have our toggle switch at the top.

00:17:13.128 --> 00:17:16.690
Next thing we need to do is now put
the class name and the ID.

00:17:18.190 --> 00:17:19.306
So I'll come to the block.

00:17:20.333 --> 00:17:21.413
I'll go under the style tab

00:17:21.798 --> 00:17:24.966
and I'll give it a class name of…

00:17:27.462 --> 00:17:32.156
dd-content-section.

00:17:33.966 --> 00:17:37.054
Since this is the first one, I'll
give it another class name

00:17:37.079 --> 00:17:38.804
just with a space and say active.

00:17:40.482 --> 00:17:42.333
Then for the second one,

00:17:43.357 --> 00:17:44.466
it's the same class name.

00:17:44.466 --> 00:17:47.099
So dd-ontent-section.

00:17:48.066 --> 00:17:49.066
That goes away.

00:17:49.799 --> 00:17:52.369
And now we just need
to give them their IDs.

00:17:52.394 --> 00:17:54.336
So this is the second block.

00:17:54.361 --> 00:17:58.466
So I'll say dd-ltem2-content.

00:17:59.800 --> 00:18:01.123
The other one is…

00:18:02.000 --> 00:18:05.530
dd-item1-content.

00:18:06.264 --> 00:18:07.933
And basically, that's it.

00:18:09.221 --> 00:18:12.659
So let me just make sure I change
some of the parameters so we know.

00:18:12.684 --> 00:18:14.584
So for the yearly one,

00:18:15.597 --> 00:18:17.182
I'll go to the content tab.

00:18:18.587 --> 00:18:21.563
Then let me just give it something else.

00:18:23.931 --> 00:18:28.896
Say maybe the price is $2.99.

00:18:29.974 --> 00:18:31.286
And save that.

00:18:32.036 --> 00:18:34.488
Because it's hidden, that's why
you can't see it now.

00:18:34.513 --> 00:18:38.750
But if you want to style it, you might as
well first remove the class names.

00:18:38.775 --> 00:18:41.158
Then do your styling.
Then put the class name back.

00:18:41.205 --> 00:18:43.087
The dd-content-section.

00:18:43.953 --> 00:18:46.908
So once we have this, I can now go ahead
and preview it on the front end.

00:18:46.933 --> 00:18:48.053
So I'll go to the front end.

00:18:48.717 --> 00:18:52.566
And you see, we can toggle
this on and off.

00:18:53.279 --> 00:18:54.809
Let me go ahead and centre it.

00:18:54.834 --> 00:18:56.388
So I'll come back to this container.

00:18:56.928 --> 00:18:58.396
Make sure everything is centered.

00:18:58.421 --> 00:19:00.390
So centre, centre.

00:19:01.054 --> 00:19:02.406
So everything is centered.

00:19:02.431 --> 00:19:03.431
Save.

00:19:04.921 --> 00:19:06.281
Then we go back.

00:19:06.800 --> 00:19:07.800
Refresh.

00:19:08.996 --> 00:19:10.636
And we get the items.

00:19:10.661 --> 00:19:14.425
So toggle between monthly and yearly.

00:19:15.160 --> 00:19:17.611
If you look at the code, let's
go ahead and inspect it.

00:19:20.385 --> 00:19:22.868
We're using field set legend.

00:19:22.893 --> 00:19:28.608
And the input we're using is
the type of radio.

00:19:29.139 --> 00:19:35.061
Because we are toggling between two
separate or distinct items.

00:19:35.459 --> 00:19:40.137
If it's just one item that we're toggling
on or off, we can just use a button

00:19:40.731 --> 00:19:43.536
with an aria-pressed and
role equal to switch.

00:19:43.809 --> 00:19:49.633
Or we can use the input type equal to
checkbox, roll equal to switch.

00:19:49.829 --> 00:19:51.790
And then we can just toggle it on and off.

00:19:51.815 --> 00:19:53.386
So that will just be toggling on, off.

00:19:53.821 --> 00:19:58.443
But using on, off does not
provide enough information

00:19:58.468 --> 00:20:01.085
that we are switching
between yearly to monthly.

00:20:01.429 --> 00:20:03.476
So that's why we're using the
radio button here.

00:20:04.399 --> 00:20:07.340
And if you are a BricksExtras user,

00:20:07.365 --> 00:20:13.533
I believe they already have one toggle
switch that is built into Bricks Extras.

00:20:13.533 --> 00:20:17.328
And I believe they are also using the
same pattern of radio buttons.

00:20:17.353 --> 00:20:24.418
I haven't tested it, but I know that David,
he is into accessibility a lot as well.

00:20:24.848 --> 00:20:29.265
He doesn't say so much in the groups, but
I know he cares about accessibility and

00:20:29.290 --> 00:20:32.223
most of his elements tend
to be accessible.

00:20:33.179 --> 00:20:34.593
So yeah, that's it.

00:20:34.921 --> 00:20:36.000
Thanks for watching.

00:20:36.199 --> 00:20:37.399
I hope you enjoyed the video.

00:20:37.399 --> 00:20:39.466
If you did, please do give it a thumbs up.

00:20:40.140 --> 00:20:43.184
If you want to learn
more about any of these things,

00:20:43.209 --> 00:20:44.862
please do let me know
in the comment section

00:20:44.887 --> 00:20:47.992
and I'll try to go
over them in more details.

00:20:48.017 --> 00:20:50.527
And I'll try to leave
them in the description

00:20:50.552 --> 00:20:54.784
where you can find out more resources
to study about all of these items.

00:20:55.419 --> 00:21:00.924
So until next time, keep designing and
keep caring about accessibility.

00:21:01.604 --> 00:21:02.800
Bye.