using tailwindcss create a base.html template for django for a dashboard project. has to…
- User
using tailwindcss create a base.html template for django for a dashboard project. has to be mobile friendly with propre navigation
Assistant
Here's a mobile-friendly base.html template for a Django dashboard project using Tailwind CSS:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %}Dashboard{% endblock %}</title> <!-- Tailwind CSS CDN (you can also use your own compiled version) --> <script src="https://cdn.tailwindcss.com"></script> <!-- Additional Styles --> {% block extra_css %}{% endblock %} </head> <body class="bg-gray-100"> <!-- Mobile Navigation Bar --> <nav class="bg-white shadow-lg md:hidden fixed bottom-0 w-full"> <div class="flex justify-around items-center h-16"> <a href="{% url 'dashboard' %}" class="text-gray-600 hover:text-blue-500"> <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path> </svg> </a> <a href="{% url 'analytics' %}" class="text-gray-600 hover:text-blue-500"> <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path> </svg> </a> <a href="{% url 'settings' %}" class="text-gray-600 hover:text-blue-500"> <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path> </svg> </a> </div> </nav> <!-- Desktop Sidebar --> <aside class="hidden md:flex md:flex-col md:w-64 md:fixed md:inset-y-0 bg-white shadow-lg"> <div class="flex items-center justify-center h-20 border-b"> <span class="text-2xl font-semibold text-gray-800">Dashboard</span> </div> <nav class="mt-8"> <div class="px-4 space-y-2"> <a href="{% url 'dashboard' %}" class="flex items-center px-4 py-3 text-gray-600 hover:bg-gray-100 hover:text-blue-500 rounded-lg"> <svg class="w-5 h-5 mr-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path> </svg> Dashboard </a> <a href="{% url 'analytics' %}" class="flex items-center px-4 py-3 text-gray-600 hover:bg-gray-100 hover:text-blue-500 rounded-lg"> <svg class="w-5 h-5 mr-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path> </svg> Analytics </a> <a href="{% url 'settings' %}" class="flex items-center px-4 py-3 text-gray-600 hover:bg-gray-100 hover:text-blue-500 rounded-lg"> <svg class="w-5 h-5 mr-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path> </svg> Settings </a> </div> </nav> </aside> <!-- Main Content --> <main class="md:ml-64 pb-16 md:pb-0"> <!-- Top Header --> <header class="bg-white shadow-sm"> <div class="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8"> <div class="flex items-center justify-between"> <h1 class="text-2xl font-semibold text-gray-900"> {% block header %}Dashboard{% endblock %} </h1> <!-- User Profile Dropdown --> <div class="relative"> <button class="flex items-center space-x-2 text-gray-700 hover:text-gray-900"> <img class="h-8 w-8 rounded-full" src="https://ui-avatars.com/api/?name=User" alt="User avatar"> <span class="hidden md:inline">User Name</span> </button> </div> </div> </div> </header> <!-- Page Content --> <div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8"> {% block content %} {% endblock %} </div> </main> <!-- Additional Scripts --> {% block extra_js %}{% endblock %} </body> </html>This template includes:
- A responsive layout that works on both mobile and desktop
- A bottom navigation bar for mobile devices
- A sidebar navigation for desktop devices
- A top header with user profile
- Proper content area with padding
- Block tags for extending the template
- SVG icons for navigation items
To use this template:
-
Save it as
base.htmlin your templates directory -
Create your other templates extending this base template:
{% extends 'base.html' %} {% block title %}Page Title{% endblock %} {% block header %}Page Header{% endblock %} {% block content %} <!-- Your page content here --> {% endblock %}- Make sure you have the corresponding URLs in your
urls.py:
- 'dashboard'
- 'analytics'
- 'settings'
- For better performance, you might want to:
- Replace the Tailwind CDN with a compiled CSS file
- Add your own logo
- Customize the color scheme
- Add more navigation items as needed
- Implement the user profile dropdown functionality
- Add active states for navigation items
The template is mobile-first and will adjust its layout based on the screen size. On mobile devices, the navigation is at the bottom, while on desktop devices, it appears as a sidebar.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.