# Default styles off

Maplace.js's styles off and nothing in their place: the map and its list as your page shows them, with no CSS but a height.

## How it works

Maplace.js's own styles switched off and nothing put in their place: the map and its list exactly as your page shows them with no CSS of yours but the one rule a map can't do without, its height.

- **Off with the defaults**: the map's height, the list beside it, the list's spacing, its hover and selected looks and its scrolling, and the popups' dark text and inset, and on MapLibre their heading's weight and its room beside the close button. On a dark page, give `.maplace-popup` and `.maplace-popup-heading` a dark colour: their text takes the page's on the white bubble ([Turning them off](/styling/#turning-them-off)).
- **HTML**: `data-maplace-unstyled` on `<maplace-map>`, and a height on its `.maplace-map-pane`: the map fills it, and the list goes under it.
- **Script** and **Bundler**: `data-maplace-unstyled` on the element holding the map and its list, and a height on the map's container.
- **React**: the same attribute on the element around `<MaplaceMap>` and `<LocationList>`, and a height on the map's class.
- **On this site**: the site's own styles stay out of anything inside `data-maplace-unstyled`, its keyboard focus ring apart, so what shows here is what your page shows: the list takes the site's font and text colour as it would take yours. To draw a look of your own, style the classes Maplace.js's markup carries ([Classes](/styling/#classes)).

## Code

### HTML on MapLibre

`packages/maplace/examples/unstyled/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- No default styles: data-maplace-unstyled turns Maplace.js's own off inside the map (its height,
     the list's layout and looks, the popups' text), and nothing takes their place: the map and its
     list as your page shows them, with no CSS of yours but the map's height. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-map .maplace-map-pane { height: 24rem; }
</style>
<maplace-map id="unstyled-maplibre-map" list data-maplace-unstyled>
  <maplace-location location-id="rome" lat="41.9028" lng="12.4964" title="Rome">
    <template><p>Capital of Italy.</p></template>
  </maplace-location>
  <maplace-location location-id="milan" lat="45.4642" lng="9.19" title="Milan">
    <template><p>Finance and fashion.</p></template>
  </maplace-location>
  <maplace-location location-id="naples" lat="40.8518" lng="14.2681" title="Naples">
    <template><p>Pizza's home town.</p></template>
  </maplace-location>
  <maplace-location location-id="venice" lat="45.4408" lng="12.3155" title="Venice">
    <template><p>Built on water.</p></template>
  </maplace-location>
</maplace-map>
```

### HTML on Google

`packages/maplace/examples/unstyled/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- No default styles: data-maplace-unstyled turns Maplace.js's own off inside the map (its height,
     the list's layout and looks, the popups' text), and nothing takes their place: the map and its
     list as your page shows them, with no CSS of yours but the map's height. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-map .maplace-map-pane { height: 24rem; }
</style>
<maplace-map id="unstyled-map" api-key="YOUR_KEY" list data-maplace-unstyled>
  <maplace-location location-id="rome" lat="41.9028" lng="12.4964" title="Rome">
    <template><p>Capital of Italy.</p></template>
  </maplace-location>
  <maplace-location location-id="milan" lat="45.4642" lng="9.19" title="Milan">
    <template><p>Finance and fashion.</p></template>
  </maplace-location>
  <maplace-location location-id="naples" lat="40.8518" lng="14.2681" title="Naples">
    <template><p>Pizza's home town.</p></template>
  </maplace-location>
  <maplace-location location-id="venice" lat="45.4408" lng="12.3155" title="Venice">
    <template><p>Built on water.</p></template>
  </maplace-location>
</maplace-map>
```

### Script on MapLibre

`packages/maplace/examples/unstyled/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, what the map and its list mount on, inside data-maplace-unstyled, and the map made with Maplace; no CSS of yours but the map's height. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-script-map { height: 24rem; }
</style>
<div id="unstyled-maplibre-script-map-and-list" data-maplace-unstyled>
  <div id="unstyled-maplibre-script-map"></div>
  <div id="unstyled-maplibre-script-list"></div>
</div>
<script type="module">
  const locations = [
    { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", content: () => popupOf("Capital of Italy.") },
    { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", content: () => popupOf("Finance and fashion.") },
    { id: "naples", lat: 40.8518, lng: 14.2681, title: "Naples", content: () => popupOf("Pizza's home town.") },
    { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", content: () => popupOf("Built on water.") },
  ];

  Maplace.createMapLibreMap("#unstyled-maplibre-script-map", {
    locations,
    list: { container: "#unstyled-maplibre-script-list" },
  });

  /** A popup's content: a line about the place, under its title (the popup's heading). */
  function popupOf(about) {
    const text = document.createElement("p");
    text.textContent = about;
    return text;
  }
</script>
```

### Script on Google

`packages/maplace/examples/unstyled/script.html`

```html
<!doctype html>
<!-- A page of your own script: the CDN script, what the map and its list mount on, inside data-maplace-unstyled, and the map made with Maplace, which adds Maps JS with your key; no CSS of yours but the map's height. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-script-map { height: 24rem; }
</style>
<div id="unstyled-script-map-and-list" data-maplace-unstyled>
  <div id="unstyled-script-map"></div>
  <div id="unstyled-script-list"></div>
</div>
<script type="module">
  const locations = [
    { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", content: () => popupOf("Capital of Italy.") },
    { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", content: () => popupOf("Finance and fashion.") },
    { id: "naples", lat: 40.8518, lng: 14.2681, title: "Naples", content: () => popupOf("Pizza's home town.") },
    { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", content: () => popupOf("Built on water.") },
  ];

  Maplace.createGoogleMap("#unstyled-script-map", {
    apiKey: "YOUR_KEY",
    locations,
    list: { container: "#unstyled-script-list" },
  });

  /** A popup's content: a line about the place, under its title (the popup's heading). */
  function popupOf(about) {
    const text = document.createElement("p");
    text.textContent = about;
    return text;
  }
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/unstyled/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-vanilla-map { height: 24rem; }
</style>
<div id="unstyled-maplibre-vanilla-map-and-list" data-maplace-unstyled>
  <div id="unstyled-maplibre-vanilla-map"></div>
  <div id="unstyled-maplibre-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/unstyled/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";

const locations: Location[] = [
  {
    id: "rome",
    lat: 41.9028,
    lng: 12.4964,
    title: "Rome",
    content: () => popupOf("Capital of Italy."),
  },
  {
    id: "milan",
    lat: 45.4642,
    lng: 9.19,
    title: "Milan",
    content: () => popupOf("Finance and fashion."),
  },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    content: () => popupOf("Pizza's home town."),
  },
  {
    id: "venice",
    lat: 45.4408,
    lng: 12.3155,
    title: "Venice",
    content: () => popupOf("Built on water."),
  },
];

createMapLibreMap("#unstyled-maplibre-vanilla-map", {
  locations,
  list: { container: "#unstyled-maplibre-vanilla-list" },
});

/** A popup's content: a line about the place, under its title (the popup's heading). */
function popupOf(about: string): HTMLParagraphElement {
  const text = document.createElement("p");
  text.textContent = about;
  return text;
}
```

### Bundler on Google

`packages/maplace/examples/unstyled/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-vanilla-map { height: 24rem; }
</style>
<div id="unstyled-vanilla-map-and-list" data-maplace-unstyled>
  <div id="unstyled-vanilla-map"></div>
  <div id="unstyled-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/unstyled/vanilla.ts`

```ts
import type { Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";

const locations: Location[] = [
  {
    id: "rome",
    lat: 41.9028,
    lng: 12.4964,
    title: "Rome",
    content: () => popupOf("Capital of Italy."),
  },
  {
    id: "milan",
    lat: 45.4642,
    lng: 9.19,
    title: "Milan",
    content: () => popupOf("Finance and fashion."),
  },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    content: () => popupOf("Pizza's home town."),
  },
  {
    id: "venice",
    lat: 45.4408,
    lng: 12.3155,
    title: "Venice",
    content: () => popupOf("Built on water."),
  },
];

createGoogleMap("#unstyled-vanilla-map", {
  locations,
  list: { container: "#unstyled-vanilla-list" },
});

/** A popup's content: a line about the place, under its title (the popup's heading). */
function popupOf(about: string): HTMLParagraphElement {
  const text = document.createElement("p");
  text.textContent = about;
  return text;
}
```

### React on MapLibre

`packages/maplace/examples/unstyled/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-react-root .map { height: 24rem; }
</style>
<div id="unstyled-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/unstyled/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/** Your own field, in each location's `data`: a line about the place. */
interface City {
  readonly about: string;
}

const cities: Location<City>[] = [
  { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", data: { about: "Capital of Italy." } },
  { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", data: { about: "Finance and fashion." } },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    data: { about: "Pizza's home town." },
  },
  { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", data: { about: "Built on water." } },
];

// Outside the component, so a render of the page around it doesn't render every popup again.
const popupContent = ({ data }: Location<City>) => <p>{data?.about}</p>;

function Unstyled() {
  return (
    <MaplaceProvider locations={cities}>
      {/* Maplace.js's own styles are off inside, and nothing takes their place: no CSS but the map's height. */}
      <div className="map-and-list" data-maplace-unstyled="">
        <MaplaceMap
          createAdapter={createMapLibreAdapter}
          className="map"
          popupContent={popupContent}
        />
        <LocationList />
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("unstyled-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <Unstyled />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/unstyled/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-react-root .map { height: 24rem; }
</style>
<div id="unstyled-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/unstyled/react.tsx`

```tsx
import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/** Your own field, in each location's `data`: a line about the place. */
interface City {
  readonly about: string;
}

const cities: Location<City>[] = [
  { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", data: { about: "Capital of Italy." } },
  { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", data: { about: "Finance and fashion." } },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    data: { about: "Pizza's home town." },
  },
  { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", data: { about: "Built on water." } },
];

// Outside the component, so a render of the page around it doesn't render every popup again.
const popupContent = ({ data }: Location<City>) => <p>{data?.about}</p>;

function Unstyled() {
  return (
    <MaplaceProvider locations={cities}>
      {/* Maplace.js's own styles are off inside, and nothing takes their place: no CSS but the map's height. */}
      <div className="map-and-list" data-maplace-unstyled="">
        <MaplaceMap
          createAdapter={createGoogleAdapter}
          className="map"
          popupContent={popupContent}
        />
        <LocationList />
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("unstyled-react-root") as HTMLElement).render(
  <StrictMode>
    <Unstyled />
  </StrictMode>,
);
```
