<div class='flex flex-col items-center justify-center w-screen h-screen gap-6 '> <div…
- User
- Assistant
To make your tabs have a 3D animation effect similar to the 3D button you provided, you can apply similar styles and animations to the tabs. Below is the modified code integrating the 3D animation into the tabs:
HTML:
<div role="tablist" class="flex flex-col items-center justify-center w-screen h-screen gap-6">
<div class="flex space-x-4">
<button
type="button"
role="tab"
class="tab w-40 h-16 bg-blue-500 rounded-lg cursor-pointer select-none
active:translate-y-2 active:[box-shadow:0_0px_0_0_#1b6ff8,0_0px_0_0_#1b70f841]
active:border-b-[0px]
transition-all duration-150 [box-shadow:0_10px_0_0_#1b6ff8,0_15px_0_0_#1b70f841]
border-b-[1px] border-blue-400
text-white font-bold text-lg
focus:outline-none"
aria-selected="true"
aria-controls="tab-content-1"
>
Tab 1
</button>
<button
type="button"
role="tab"
class="tab w-40 h-16 bg-blue-500 rounded-lg cursor-pointer select-none
active:translate-y-2 active:[box-shadow:0_0px_0_0_#1b6ff8,0_0px_0_0_#1b70f841]
active:border-b-[0px]
transition-all duration-150 [box-shadow:0_10px_0_0_#1b6ff8,0_15px_0_0_#1b70f841]
border-b-[1px] border-blue-400
text-white font-bold text-lg
focus:outline-none"
aria-selected="false"
aria-controls="tab-content-2"
>
Tab 2
</button>
<button
type="button"
role="tab"
class="tab w-40 h-16 bg-blue-500 rounded-lg cursor-pointer select-none
active:translate-y-2 active:[box-shadow:0_0px_0_0_#1b6ff8,0_0px_0_0_#1b70f841]
active:border-b-[0px]
transition-all duration-150 [box-shadow:0_10px_0_0_#1b6ff8,0_15px_0_0_#1b70f841]
border-b-[1px] border-blue-400
text-white font-bold text-lg
focus:outline-none"
aria-selected="false"
aria-controls="tab-content-3"
>
Tab 3
</button>
</div>
<div
id="tab-content-1"
role="tabpanel"
class="tab-content bg-base-100 border-base-300 rounded-box p-6 mt-4"
>
Tab content 1
</div>
<div
id="tab-content-2"
role="tabpanel"
class="tab-content bg-base-100 border-base-300 rounded-box p-6 mt-4 hidden"
>
Tab content 2
</div>
<div
id="tab-content-3"
role="tabpanel"
class="tab-content bg-base-100 border-base-300 rounded-box p-6 mt-4 hidden"
>
Tab content 3
</div>
</div>
JavaScript (for tab functionality and interaction):
// Get all tab buttons and panels
const tabs = document.querySelectorAll('[role="tab"]');
const tabPanels = document.querySelectorAll('[role="tabpanel"]');
// Add click event listeners to each tab
tabs.forEach((tab) => {
tab.addEventListener('click', () => {
// Deactivate all tabs
tabs.forEach((t) => {
t.setAttribute('aria-selected', 'false');
t.classList.remove('bg-blue-600');
});
// Hide all tab panels
tabPanels.forEach((panel) => {
panel.classList.add('hidden');
});
// Activate clicked tab
tab.setAttribute('aria-selected', 'true');
tab.classList.add('bg-blue-600');
// Show associated tab panel
const tabPanel = document.getElementById(tab.getAttribute('aria-controls'));
tabPanel.classList.remove('hidden');
});
});
Explanation:
HTML Adjustments:
input elements with button elements. This change allows us to apply more complex styles and animations directly to the tabs.aria-selected and aria-controls to manage active states and accessibility.w-40 h-16), background color (bg-blue-500), border radius (rounded-lg), and the 3D animation effect.focus:outline-none to remove the default focus outline, making the design cleaner.JavaScript Functionality:
aria-selected="false" and the active styling is removed.aria-selected="true" and given an additional class (e.g., bg-blue-600) to indicate it is active.hidden class.aria-controls) is displayed by removing the hidden class.CSS (Utility Classes):
active:translate-y-2: Moves the tab down slightly when active (pressed).active:[box-shadow:0_0px_0_0_#1b6ff8,0_0px_0_0_#1b70f841]: Removes the box-shadow when the tab is active, creating a pressed effect.[box-shadow:0_10px_0_0_#1b6ff8,0_15px_0_0_#1b70f841]: Adds a box-shadow to create the 3D raised effect.transition-all duration-150: Smooths the transition between states.border-b-[1px] border-blue-400: Adds a bottom border that disappears when the tab is active.hidden class in your CSS that sets to hide elements when needed.Note: The classes like active:[box-shadow:...] and [box-shadow:...] are using Tailwind CSS's arbitrary values feature. Make sure your Tailwind configuration allows arbitrary properties and values.
Tailwind CSS Configuration (if required):
If you're using Tailwind CSS, ensure that arbitrary properties are enabled in your tailwind.config.js:
module.exports = {
// ...
safelist: [
{
pattern: /./, // Allows all classes (use with caution)
},
],
// ...
};
Final Remarks:
By applying the same styles and animations from your 3D button to your tabs, you achieve a consistent and interactive design. Users will experience a smooth 3D press effect when they click on the tabs, enhancing the overall user interface.
Remember to include the necessary JavaScript code to handle the tab switching logic. Test the tabs to ensure they respond correctly to clicks and display the appropriate content.
I hope this helps you incorporate the 3D animation into your tabs! Let me know if you have any questions or need further assistance.
Not yet included in a published release.
display: none;