ShadCN Vaults

Back to Blocks

Security Alert Access Control

Confidential Access Block

Confidential Access Component

Security Alert Access Control

Confidential access page with security alerts, permission levels, and administrator contact options

Preview

Full width desktop view

Code

confidential-4.tsx
1"use client";
2
3import * as React from "react";
4import { cva, type VariantProps } from "class-variance-authority";
5
6import { Lock, Shield, AlertTriangle } from "lucide-react";
7import { Button } from "@/components/ui/button";
8
9const cn = (...classes: (string | undefined)[]) =>
10  classes.filter(Boolean).join(" ");
11
12const alertVariants = cva("relative rounded-lg border", {
13  variants: {
14    variant: {
15      default: "border-border bg-background",
16      warning: "border-amber-500/50 text-amber-600",
17      error: "border-red-500/50 text-red-600",
18      success: "border-emerald-500/50",
19      info: "border-blue-500/50 text-blue-600",
20    },
21    size: {
22      sm: "px-4 py-3",
23      lg: "p-4",
24    },
25    isNotification: {
26      true: "z-[100] max-w-[400px] bg-background shadow-lg shadow-black/5",
27      false: "",
28    },
29  },
30  defaultVariants: {
31    variant: "default",
32    size: "sm",
33    isNotification: false,
34  },
35});
36
37interface AlertProps
38  extends React.HTMLAttributes<HTMLDivElement>,
39    VariantProps<typeof alertVariants> {
40  icon?: React.ReactNode;
41  action?: React.ReactNode;
42  layout?: "row" | "complex";
43}
44
45const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
46  (
47    {
48      className,
49      variant,
50      size,
51      isNotification,
52      icon,
53      action,
54      layout = "row",
55      children,
56      ...props
57    },
58    ref
59  ) => (
60    <div
61      ref={ref}
62      role="alert"
63      className={cn(
64        alertVariants({ variant, size, isNotification }),
65        className
66      )}
67      {...props}
68    >
69      {layout === "row" ? (
70        <div className="flex items-center gap-2">
71          <div className="grow flex items-center">
72            {icon && <span className="me-3 inline-flex">{icon}</span>}
73            {children}
74          </div>
75          {action && <div className="flex items-center shrink-0">{action}</div>}
76        </div>
77      ) : (
78        <div className="flex gap-2">
79          {icon && children ? (
80            <div className="flex grow gap-3">
81              <span className="mt-0.5 shrink-0">{icon}</span>
82              <div className="grow">{children}</div>
83            </div>
84          ) : (
85            <div className="grow">
86              {icon && <span className="me-3 inline-flex">{icon}</span>}
87              {children}
88            </div>
89          )}
90          {action && <div className="shrink-0">{action}</div>}
91        </div>
92      )}
93    </div>
94  )
95);
96Alert.displayName = "Alert";
97
98const ConfidentialAccessPage = () => {
99  return (
100    <div className="min-h-screen bg-background flex items-center justify-center p-4">
101      <div className="w-full max-w-md space-y-8">
102        <div className="text-center">
103          <div className="mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4">
104            <Lock className="w-8 h-8 text-red-600" />
105          </div>
106          <h1 className="text-2xl font-bold text-foreground mb-2">
107            Confidential Access
108          </h1>
109          <p className="text-muted-foreground">
110            This content is restricted and requires special permissions to
111            access.
112          </p>
113        </div>
114
115        <Alert
116          variant="error"
117          layout="complex"
118          icon={<AlertTriangle size={16} />}
119        >
120          <div>
121            <h3 className="font-medium text-sm mb-1">Access Denied</h3>
122            <p className="text-xs text-muted-foreground">
123              You don't have the necessary permissions to view this content.
124            </p>
125          </div>
126        </Alert>
127
128        <div className="space-y-4">
129          <div className="bg-muted/50 rounded-lg p-4 space-y-3">
130            <div className="flex items-center gap-3">
131              <Shield className="w-5 h-5 text-blue-600" />
132              <div>
133                <h3 className="font-medium text-sm">Security Level: High</h3>
134                <p className="text-xs text-muted-foreground">
135                  Requires administrator approval
136                </p>
137              </div>
138            </div>
139          </div>
140
141          <div className="space-y-3">
142            <Button className="w-full" variant="outline">
143              Request Access
144            </Button>
145            <Button className="w-full" variant="ghost">
146              Contact Administrator
147            </Button>
148          </div>
149        </div>
150      </div>
151    </div>
152  );
153};
154
155const ConfidentialAccessDemo = () => {
156  return (
157    <div className="space-y-4">
158      <ConfidentialAccessPage />
159    </div>
160  );
161};
162
163export default ConfidentialAccessDemo;

Dependencies

External Libraries

class-variance-authoritylucide-reactreact

Shadcn/UI Components

button

LICENSE

MIT License

Copyright (c) 2025 Aldhaneka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Shadcn Vaults Project (CC BY-NC 4.0 with Internal Use Exception)

All user-submitted components in the '/blocks' directory are licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0),
with the following clarification and exception:

You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material

Under these conditions:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
- NonCommercial — You may NOT use the material for commercial redistribution, resale, or monetization.

🚫 You MAY NOT:
- Sell or redistribute the components individually or as part of a product (e.g. a UI kit, template marketplace, SaaS component library)
- Offer the components or derivative works in any paid tool, theme pack, or design system

✅ You MAY:
- Use the components in internal company tools, dashboards, or applications that are not sold as products
- Remix or adapt components for private or enterprise projects
- Use them in open-source non-commercial projects

This license encourages sharing, learning, and internal innovation — but prohibits using these components as a basis for monetized products.

Full license text: https://creativecommons.org/licenses/by-nc/4.0/

By submitting a component, contributors agree to these terms.

For questions about licensing, please contact the project maintainers.