Comments (2)
I was facing the same problem. Current installation steps are invalid for Remix 2.8.1.
I managed to fix the problem:
-
Install preline
npm install preline
-
Add the path to Preline UI JavaScript files in your tailwind.config.js file.
// tailwind.config.js
module.exports = {
content: [
'./node_modules/preline/preline.js',
],
plugins: [
require('preline/plugin'),
],
}
- Create
preline.client.tsx
file for example in ~/components folder. (We will use client module):
import {
useLocation,
} from "@remix-run/react";
import { useEffect } from "react";
import { IStaticMethods } from "preline/preline";
declare global {
interface Window {
HSStaticMethods: IStaticMethods;
}
}
export default function PrelineScript() {
const location = useLocation();
useEffect(() => {
import("preline/preline");
}, []);
useEffect(() => {
setTimeout(() => {
window.HSStaticMethods.autoInit();
}, 100);
}, [location.pathname]);
return null;
}
- Connect this file in
root.tsx
:
...
// Import at top of file
import PrelineScript from "~/components/preline.client";
export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
{/* Add preline script on every page */}
{PrelineScript && <PrelineScript />}
</body>
</html>
);
}
...
from preline.
`declare global {
interface Window {
HSStaticMethods: IStaticMethods;
}
}
if (typeof window !== "undefined") {
await import('preline/preline');
}
export function Layout({ children }: { children: ReactNode }) {
const location = useLocation();
useEffect(() => {
window.HSStaticMethods.autoInit();
}, [location.pathname]);
return ( ... )
`
Replace typeof window !== "undefined"
with typeof document !== "undefined"
to handle runtimes outside of Node like Deno. Read the Remix Gotchas for more info.
from preline.
Related Issues (20)
- Offcanvas is not working for me HOT 1
- No support for Decimal on Input number element HOT 2
- Angular version of Accordion doesn't work HOT 1
- [React] How to collapse the navbar Links after clicking on a link? HOT 1
- Can you support AdonisJS
- Searchable advanced select throws error when searching for value not in list
- aria-expanded is not present in collapse button
- Add support to escape ID for React's useId hook HOT 1
- 关于如何在React Vite ts中激活js交互的参考
- Combobox will skip at least one item if arrowdown/up in vue3 HOT 1
- Error while filling the input in the Preline UI component HOT 2
- Carousel Plugin Bug: Incorrect Behavior in RTL dir
- Accordion/Collapse panel markup missing `role="region"` HOT 1
- Dropdown menu doesn't open if child contains `onclick` or `data-hs-overlay` HOT 2
- Interactivity missing in Umbraco CMS HOT 1
- I can't build my nextjs v14 app using preline
- Laravel 11 Livewire 3 issue rendering classes. HOT 2
- Advanced select's documentation copies invalid JSON when used without dark classes
- Cannot read properties of undefined (reading 'getAttribute') In Next JS 14 HOT 1
- data-hs-combo-box-output-item attribute hydration issues HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preline.