maud-ui 0.1.0

58 headless, accessible UI components for Rust web apps. Built on maud + htmx, styled like shadcn/ui.
Documentation
/* Drawer Component Styles */

dialog.mui-drawer {
  margin: 0;
  padding: 0;
  border: none;
  background: var(--mui-bg-card);
  color: var(--mui-text);
  box-shadow: var(--mui-shadow-lg);
  max-width: 24rem;
  width: 85vw;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

dialog.mui-drawer[open] {
  display: flex;
  flex-direction: column;
}

dialog.mui-drawer::backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  animation: mui-drawer-backdrop-enter 150ms ease-out;
}

@keyframes mui-drawer-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Right drawer — anchored to the right edge, rounded left corners */
dialog.mui-drawer--right {
  margin-left: auto;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  border-radius: var(--mui-radius-lg) 0 0 var(--mui-radius-lg);
  animation: mui-drawer-slide-right 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mui-drawer-slide-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Left drawer — anchored to the left edge, rounded right corners */
dialog.mui-drawer--left {
  margin-right: auto;
  margin-left: 0;
  margin-top: 0;
  margin-bottom: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 0 var(--mui-radius-lg) var(--mui-radius-lg) 0;
  animation: mui-drawer-slide-left 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mui-drawer-slide-left {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* Top drawer — anchored to the top edge, rounded bottom corners */
dialog.mui-drawer--top {
  width: 100vw;
  max-width: 100vw;
  height: auto;
  max-height: 50vh;
  margin-bottom: auto;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  border-radius: 0 0 var(--mui-radius-lg) var(--mui-radius-lg);
  animation: mui-drawer-slide-top 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mui-drawer-slide-top {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Bottom drawer — anchored to the bottom edge, rounded top corners */
dialog.mui-drawer--bottom {
  width: 100vw;
  max-width: 100vw;
  height: auto;
  max-height: 85vh;
  margin-top: auto;
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: var(--mui-radius-lg) var(--mui-radius-lg) 0 0;
  animation: mui-drawer-slide-bottom 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mui-drawer-slide-bottom {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Grab handle — centered bar at top of bottom/top drawers */
.mui-drawer__handle {
  display: flex;
  justify-content: center;
  padding: 0.75rem 0 0;
}

.mui-drawer__handle-bar {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 9999px;
  background: var(--mui-text-muted);
  opacity: 0.4;
}

.mui-drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0;
}

.mui-drawer__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.mui-drawer__close {
  background: transparent;
  border: 1px solid var(--mui-border);
  color: var(--mui-text);
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--mui-radius-sm);
  font-size: 1.125rem;
  line-height: 1;
  transition: background var(--mui-transition), border-color var(--mui-transition);
  flex-shrink: 0;
}

.mui-drawer__close:hover {
  background: var(--mui-bg-hover);
  border-color: var(--mui-border-hover, var(--mui-border));
}

.mui-drawer__close:focus-visible {
  outline: 2px solid var(--mui-border-focus);
  outline-offset: 2px;
}

.mui-drawer__close:active {
  opacity: 0.7;
}

.mui-drawer__description {
  padding: 0.25rem 1.5rem 0;
  margin: 0;
  color: var(--mui-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.mui-drawer__body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.mui-drawer__body > *:last-child {
  margin-bottom: 0;
}

/* Footer for action buttons pinned at bottom */
.mui-drawer__footer {
  padding: 1.5rem;
  border-top: 1px solid var(--mui-border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Mobile: side drawers take nearly full width, reduce interior padding */
@media (max-width: 640px) {
  dialog.mui-drawer--right,
  dialog.mui-drawer--left {
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }

  .mui-drawer__header,
  .mui-drawer__description {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .mui-drawer__body {
    padding: 1rem;
  }

  .mui-drawer__footer {
    padding: 1rem;
    flex-direction: column-reverse;
  }

  .mui-drawer__footer > * {
    width: 100%;
  }
}